Skip to content
Back to formatted view

Raw Message

Message-ID: <BAY135-W1452C6B34E101E0D57E87D88900@phx.gbl>
Date: 2009-03-25T17:58:25Z
From: Steve Murray
Subject: Manual sort in a for loop

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]]