Re: [R] Automate concatenation?

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Tue 30 May 2006 - 22:33:21 EST

you need get(), look also at FAQ 7.21

a1 <- 1:3
a2 <- 4:5
a3 <- 6:10
a4 <- 11:20
a5 <- 21:25
#####################

lapply(paste("a", 1:5, sep = ""), get)

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


>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. 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="")
>
> Robert
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 30 23:42:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 31 May 2006 - 00:10:26 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.