[R] paste name in for loop?

2009-11-30 Thread Douglas M. Hultstrand
Hello, I am trying to create subsets of grouped data (by area size), and use the area size as part of the output name. The code below works for area (xout) 1 and 50, the other files are given NA for an area. A simple example: xout - c(1,5,10,25,50,100) for(i in xout) {

Re: [R] paste name in for loop?

2009-11-30 Thread Duncan Murdoch
On 30/11/2009 7:49 PM, Douglas M. Hultstrand wrote: Hello, I am trying to create subsets of grouped data (by area size), and use the area size as part of the output name. The code below works for area (xout) 1 and 50, the other files are given NA for an area. A simple example: xout -

Re: [R] paste name in for loop?

2009-11-30 Thread Jorge Ivan Velez
Hi Douglas, You were almost there. Just remember that your iterator is i and not xout. R xout - c(1,5,10,25,50,100) R for(i in xout) print(paste(Areal_Ppt_, i,sqmi.txt, sep=)) [1] Areal_Ppt_1sqmi.txt [1] Areal_Ppt_5sqmi.txt [1] Areal_Ppt_10sqmi.txt [1] Areal_Ppt_25sqmi.txt [1]

Re: [R] paste name in for loop?

2009-11-30 Thread jim holtman
Here is what you want: xout - c(1,5,10,25,50,100) for(i in xout) { print(paste(Areal_Ppt_,i,sqmi.txt, sep=)) } Notice that 'i' will be assigned each value in xout; you do not have to index into the vector. Notice that you second value is 50 which is xout[5]. On Mon, Nov 30, 2009 at 7:49 PM,