Re: [R] Sorting data frame by a string variable

2007-07-18 Thread S Ellison
Dimitri If you try order(c(b,a,c)) [1] 2 1 3 or sort(c(b,a,c)) [1] a b c You will see that sort() and order() DO respect character order. Your problem could be that your data frame variable is not a character but a factor (the default for read.table, for example) Check the class of the

[R] Sorting data frame by a string variable

2007-07-17 Thread Dimitri Liakhovitski
I have a data frame MyData with 2 variables. One of the variables (String) contains a string of letters. How can I resort MyData by MyData$String (alphabetically) and then save the output as a sorted data file? I tried: o-order(MyData$String) SortedData-rbind(MyData$String[o], MyData$Value[o])

Re: [R] Sorting data frame by a string variable

2007-07-17 Thread Peter Dalgaard
Dimitri Liakhovitski wrote: I have a data frame MyData with 2 variables. One of the variables (String) contains a string of letters. How can I resort MyData by MyData$String (alphabetically) and then save the output as a sorted data file? I tried: o-order(MyData$String)