[R] paste dataframe
Deepayan Sarkar
deepayansarkar at yahoo.com
Wed Apr 10 17:16:28 CEST 2002
--- 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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list