Re: [R] Manual sort in a for loop

2009-03-26 Thread Steve Murray
Thanks all - I'm fairly new to R, so I was oblivious to the pros and cons of using a data frame as opposed to a list! The 'get' command also seemed to work successfully. Thanks again, Steve _ 25GB of FREE Online Storage – Find

Re: [R] Manual sort in a for loop

2009-03-26 Thread Simon Pickett
I would suggest avoiding the function ?assign inside a loop. I used top use this until someone here kindly pointed out that it was much easier to catch the data of interest in a list... eg. df.list <- vector("list", length(10)) for (i in 1:10)} df.list[[i]]<-data.frame(arunoff_,table_year,_tem

Re: [R] Manual sort in a for loop

2009-03-25 Thread baptiste auguie
well, the literal answer is that paste("arunoff_",table_year,"_temp") is a character vector of length 1 so your indexing cannot work. What you want is to index the data that corresponds to this variable name, ?get But I should stress that this manipulation with assign and get seems complete

Re: [R] Manual sort in a for loop

2009-03-25 Thread jim holtman
I assume you need to use 'get' to retrieve the value: table_year=1951 for (i in (paste("arunoff_",year,"_temp",sep=""))) { assign(paste("arunoff_",table_year, sep=""),get(paste("arunoff_",table_year,"_temp"))[c(10,7,9,5,4,12,1,3,2,8,11,6),]) table_year = table_year+1 }

Re: [R] Manual sort in a for loop

2009-03-25 Thread Rowe, Brian Lee Yung (Portfolio Analytics)
Aren't you missing a sep='' in your last call to paste? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steve Murray Sent: Wednesday, March 25, 2009 1:58 PM To: r-help@r-project.org Subject: [R] Manual sort in a for loop Dear all,