Robert Lundqvist <[EMAIL PROTECTED]> writes:
> I have this typical problem of joining a number of vectors with similar
> names - a1, a2,..., a10 - which should be concatenated into one. Using
> c(a1,a2,a3,a4,a5,a6,a,a8,a9,a10) naturally works, but I would like to do
> it with less manual input.
And less error-prone (where did the "7" go?)...
> My attempts to use paste() gives a vector of
> the vector names, see below. The question is how to do the the
> concatenation? Any suggestions?
>
> paste("a",1:10,sep="")
I think this should work:
unlist(lapply( paste("a",1:10,sep=""), get))
(and of course, the usual sermon applies: You're likely better off
using a list of vectors rather than vectors with similar names.)
--
O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html