[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.


At 1:51 PM -0400 10/4/07, Nair, Murlidharan T wrote:
>If I have two vectors
>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
>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

More information about the R-help mailing list