[R] Combining columns of different length

Gabor Grothendieck ggrothendieck at myway.com
Wed Oct 27 04:14:16 CEST 2004


Federico Gherardini <f.gherardini <at> pigrecodata.net> writes:

: 
: Thanks everybody for their help but in this particular case I've found a 
: very easy solution. Since the matrix is preallocated I don't really have 
: to add a new column: given a matrix of NAs  I can simply
: 
: m[,index][1:length(vec)] <- vec
: 

You could simplify that to:

    m[seq(along=vec), index] <- vec




More information about the R-help mailing list