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

______________________________________________
R-help@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.

Reply via email to