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  
completely unnecessary (not to mention that your for loop is quite  
redundant --- what's "i" for?). Did you try to use list() to collect  
your data instead of assign()? (as i suggested to you recently)

Hope this helps,

baptiste





On 25 Mar 2009, at 17:58, Steve Murray wrote:

>
> 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 seem to successfully execute the statements when  
> incorporated into the loop. The code I have is as follows:
>
> table_year=1951
> for (i in (paste("arunoff_",year,"_temp",sep=""))) {
>          assign(paste("arunoff_",table_year,  
> sep=""),paste("arunoff_",table_year,"_temp") 
> [c(10,7,9,5,4,12,1,3,2,8,11,6),])
>          table_year = table_year+1
>          }
>
>
> The error I get is:
>
> Error in paste("arunoff_", table_year, "_temp")[c(10, 7, 9, 5, 4,  
> 12,  :
>  incorrect number of dimensions
>
> ...depsite this not occurring when I do each table individually (so  
> it can't be a case of there not being enough rows, as>  
> dim(arunoff_1951_temp) gives [1] 12 11
>
> I have a feeling that it may be a syntax error, possibly between  
> 'temp' and the square bracket, but I can't be sure of this.
>
>
> Any solutions or advice offered would be gratefully received.
>
> Many thanks,
>
> Steve
>
> _________________________________________________________________
> [[elided Hotmail spam]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________


	[[alternative HTML version deleted]]


