[R] sending a vector of characters as arguments for a function
rolf at math.unb.ca
rolf at math.unb.ca
Thu Mar 8 18:48:46 CET 2007
Pascal Boisson wrote:
<snip>
> I have variables C_1, C_2, C_3 ... that corresponds to vectors of size
> n, and I would like to cbind them.
>
> I get a vector of their names using : temp<- ls(pat="C")
>
> And I like to find a way to use this vector temp as an argument to
> cbind.
>
> Unfortunately, my various trials failed, here are some samples of what I
> tried :
<snip>
Try:
s0 <- ls(pat="^C") # Notice the ``^'' --- for safety.
m <- do.call("cbind",lapply(s0,"get")) # Names get lost.
colnames(m) <- s0 # So tack them on.
cheers,
Rolf Turner
rolf at math.unb.ca
More information about the R-help
mailing list