Re: [R] Automating object creation

2009-04-14 Thread Zachary Patterson
Wow! I wasn't expecting such quick and helpful responses. I will see which of these suggestions works best for what I am doing. Thanks very much to all of you. Zak On Tue, Apr 14, 2009 at 1:58 PM, Stavros Macrakis wrote: > It is certainly possible to create x2, x4, etc. using something like > as

Re: [R] Automating object creation

2009-04-14 Thread Stavros Macrakis
It is certainly possible to create x2, x4, etc. using something like assign( sprintf("x%d",i), ...value... ). But are you sure you need separate *variables* x2, x4, etc.? Why not create a list of vectors addressible as x[2] etc.? You can do that with x <- list() (to define the data type of x as

Re: [R] Automating object creation

2009-04-14 Thread Barry Rowlingson
On Tue, Apr 14, 2009 at 6:32 PM, Zachary Patterson wrote: > I am new to R. I would like to automate the creation of a number of > vectors but can't seem to get the string formatting to work. > > Here's what I would like to be able to do: > > Suppose we have a vector: > x <- c(2,4,5) > > I would li

Re: [R] Automating object creation

2009-04-14 Thread baptiste auguie
?assign (but are you sure you really want to name all these objects separately? Usually in R you would put them together in a list or a data.frame, it is much more convenient for later manipulations) On 14 Apr 2009, at 18:32, Zachary Patterson wrote: I am new to R. I would like to automat

[R] Automating object creation

2009-04-14 Thread Zachary Patterson
I am new to R. I would like to automate the creation of a number of vectors but can't seem to get the string formatting to work. Here's what I would like to be able to do: Suppose we have a vector: x <- c(2,4,5) I would like to be able to create a set of vectors whose names are associated with t