Re: [R] using string variable as order() function argument

2010-07-26 Thread jim holtman
Try this: > mytable id col1 col2 col3 1 10048 2 11122 3 12083 4 13055 > colName <- 'col3' > mytable[order(mytable[[colName]]),] id col1 col2 col3 2 11122 3 12083 4 13055 1 10048 > colName <- 'id' >

Re: [R] using string variable as order() function argument

2010-07-26 Thread Joshua Wiley
Hi, Is this what you want? ## mytable <- read.table(textConnection(" id col1 col2 col3 1004 8 1112 2 1208 3 1305 5 "), header = TRUE) mytable columnname <- "col3" mytable[order(mytable[, columnname]), ] ### Josh

Re: [R] using string variable as order() function argument

2010-07-26 Thread Duncan Murdoch
On 26/07/2010 2:56 PM, mirek wrote: Hello, In my script I would like to use a loop, which sorts the dataframe according to different columns, pointed by the string variable. id col1 col2 col3 1 1004 8 2 1112 2 3 1208 3 4 1305