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
noff_,table_year,_temp)[c(10,7,9,5,4,12,1,3,2,8,11,6),]
}
HTH
Simon.
- Original Message -
From: "Steve Murray"
To:
Sent: Wednesday, March 25, 2009 5:58 PM
Subject: [R] Manual sort in a for loop
Dear all,
I am trying to manually re-sort rows in a number of tables. The
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
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
}
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 l
Dear all,
I am trying to manually re-sort rows in a number of tables. The rows aren't
sorted on any particular values but are simply ordered by user choice (as shown
by the row numbers in the code). I have been able to carry out each
re-arrangement without the use of the 'for' loop, but cannot
6 matches
Mail list logo