[R] cbind function
"Jens Oehlschlägel"
oehl_list at gmx.de
Tue Nov 13 18:49:03 CET 2007
And here is a second solution, that differs in what happens if the variables have differing lengths:
> var1 <- 1:4
> var2 <- 1:3
> sapply(ls(patt="^var[0-9]"), get)
$var1
[1] 1 2 3 4
$var2
[1] 1 2 3
> do.call("cbind", lapply(ls(patt="^var[0-9]"), get))
[,1] [,2]
[1,] 1 1
[2,] 2 2
[3,] 3 3
[4,] 4 1
Warning message:
In cbind(1:4, 1:3) :
number of rows of result is not a multiple of vector length (arg 2)
Best regards
Jens Oehlschlägel
--
More information about the R-help
mailing list