Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8306775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:23:49+00:00 2026-06-08T18:23:49+00:00

This probably has a very simple answer, but I’m having trouble figuring it out…

  • 0

This probably has a very simple answer, but I’m having trouble figuring it out…

What is a vector-based way to take one value in the cell of one column in a dataframe, conditional on some criterion in a given row being satisfied, and assign it to a cell along the same row but in a different column? I’ve done it with loops over if-else statements, but I’m working with pretty big data sets, and my little laptop freezes for many minutes going through the looping conditionals.

Eg. if I have sometihng like this:

Results$TResponseCorrect[Results$rownum %in% CorrectTs$rownum] <- 1

that works fine. But what doesn’t work is something like

Results$TResponseCorrect[Results$rownum %in% CorrectTs$rownum] <- Results$TCorrect

In that case I get a warning saying, “number of items to replace is not a multiple of replacement length”, which I basically take to mean that it can’t figure out which cell of the Results$Subject column to take.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:23:50+00:00Added an answer on June 8, 2026 at 6:23 pm

    Since your problem statement implies that all these are in the same data frame you may want:

    Results$TResponseCorrect[Results$rownum %in% CorrectTs$rownum] <- 
                    Results$TCorrect[Results$rownum %in% CorrectTs$rownum]
    

    It will then have the same number of items on the LHS and the RHS of the assignment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, This question probably has a very simple answer - something I'm overlooking. But
I feel like the answer to this question is probably very simple, but I'm
There is probably a very simple answer to this question, but I can't for
This is probably a very simple question for some, but it has me stumped.
This is probably a very simple question for some, but it has me stumped.
Really having an issue debugging this...the reason why is probably very simple but I'm
This is probably very simple, but I am trying to make something with has
I know this probably has been asked before but I am having issues with
This has probably been answer already but I am trying to return the primary
I've got a question that probably has a pretty simple answer, but I didn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.