--- Olivier Martin <olivier.martin at inrialpes.fr> wrote:> Hi all, > Assume i have two dataframes A and B with characters objects > for example, > A<-rbind(c("the","is"),c("and","!")) > B<-rbind(c("car","red"),c("blue","!"))I believe these would be just matrices, and not data frames.> and i would like to obtain the C dataframe > C<-rbind(c("the "is red"),c("and blue","!!")) > > What is the solution without loops ?If you mean C<-rbind(c("the "is red"),c("and blue","! !")) you could try C <- matrix(paste(A, B), dim(A)) (this is assuming that dim(A)==dim(B), you could put a check for that). This will not work if A and B are data frames, BTW. -Deepayan __________________________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 11 Apr 2002, Olivier Martin wrote:> Hi all, > Assume i have two dataframes A and B with characters objects > for example, > A<-rbind(c("the","is"),c("and","!")) > B<-rbind(c("car","red"),c("blue","!")) > > and i would like to obtain the C dataframe > C<-rbind(c("the car", "is red"),c("and blue","!!")) > > What is the solution without loops ?One solution is matrix(paste(A,B),2) -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
apply(array(c(A,B),dim=c(2,2,2)),c(1,2),function(x)paste(x[1],x[2])) On 11 Apr 2002 at 3:24, Olivier Martin wrote:> Hi all, > Assume i have two dataframes A and B with characters objects > for example, > A<-rbind(c("the","is"),c("and","!")) > B<-rbind(c("car","red"),c("blue","!")) > > and i would like to obtain the C dataframe > C<-rbind(c("the car", "is red"),c("and blue","!!")) > > What is the solution without loops ?-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi all, Assume i have two dataframes A and B with characters objects for example, A<-rbind(c("the","is"),c("and","!")) B<-rbind(c("car","red"),c("blue","!")) and i would like to obtain the C dataframe C<-rbind(c("the car", "is red"),c("and blue","!!")) What is the solution without loops ? Thanks Olivier -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._