[R] 'Cbinding' a variable number of vectors

Marie-Pierre Sylvestre marie-pierre.sylvestre at mail.mcgill.ca
Tue Jan 27 22:10:28 CET 2004


I have a list of vectors named S11, S12, S13, etc. Vectors are of equal
length but the number of them may vary. I want to make a matrix S1 out of
them. I think 'cbind' is the best way to go. However, I would rather avoid
writing cbind(S11, S12, S13, etc) but instead use the 'sequential' nature of
the vector names to create my matrix S1. Say I have m vectors. Is there a
way to write something like:
L=1
while (L<=m) {
S1=cbind(S1,S1''L'')
}
Thanks in advance,
M-P Sylvestre




More information about the R-help mailing list