Re: [R] Automate concatenation?

From: Paul Roebuck <roebuck_at_mdanderson.org>
Date: Wed 31 May 2006 - 07:04:14 EST

On Tue, 30 May 2006, Robert Lundqvist wrote:

> 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="")

a1 <- c(5, 4)
a2 <- 2
a3 <- 6:9
cmd <- sprintf("c(%s)",
               paste("a", 1:3, sep = "", collapse = ", "))
eval(parse(text = cmd))

SIGSIG -- signature too long (core dumped)

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 Wed May 31 07:18:21 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 - 20:10:36 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.