[R] combining vectors on unequal length
Don MacQueen
macq at llnl.gov
Thu Oct 4 20:32:32 CEST 2007
Something like this, perhaps:
cbind( X,
c(Y, rep(NA,length(X)-length(Y)))
)
This just extends Y with NA instead of recycling Y.
If you are going to cbind() the vectors must be the same length. You
*must* have something there.
-Don
At 1:51 PM -0400 10/4/07, Nair, Murlidharan T wrote:
>If I have two vectors
>X<-1:10
>Y<-1:5
>When I combine them using cbind, the shorter one is repeated and
>both are made of the same length. Is there a methods that does this
>without duplicating the shorter one. I want to use this to store the
>data back to a file.
>Thanks ../Murli
>
>
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at 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.
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
More information about the R-help
mailing list