Hi everyone. I have three dataframes (A, B and C). B and C are subsets of the rows of A, for example...
> A<-as.data.frame(cbind(1:5,21:25)) > A V1 V2 1 1 21 2 2 22 3 3 23 4 4 24 5 5 25 > B<-A[1:4,] > B V1 V2 1 1 21 2 2 22 3 3 23 4 4 24 > C<-A[3:5,] > C V1 V2 3 3 23 4 4 24 5 5 25 I also have a single value called x > x<-2 Basically I want to evaluate x and if it equals 2, then replace A with B, and otherwise replace A with C. However, when I attempt this, the new version of A is only a subset of the desired dataframe. For example. > > A<-ifelse(x==2,B,C) > A [[1]] [1] 1 2 3 4 I'm sure this is simple, but haven't found a solution and would appreciate a tip. Thanks Terry Beutel ------------------------------ The information in this email together with any attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. There is no waiver of any confidentiality/privilege by your inadvertent receipt of this material. Any form of review, disclosure, modification, distribution and/or publication of this email message is prohibited, unless as a necessary part of Departmental business. If you have received this message in error, you are asked to inform the sender as quickly as possible and delete this message and any copies of this message from your computer and/or your computer system network. ------------------------------ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.