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