Hi,
I would like to sort a data frame by a column, the column to sort by has a
list of numbers 1:150 (a few numbers are missing so the total is 137) and
two letters S , Z. How can I sort it so that first I have the numbers
in running order (1,2,3,...150) and then the letters S and Z?
the column
Change that column to be a factor with the levels in the order that you
wish.
dataFrame$column - factor(dataFrame$column, levels=c(1:150, S, Z))
Then it will sort in that order. E.g.,
d - data.frame(One=c(5,21,10,Z,S,9), Two=2^(1:6))
d[order(d$One),]
One Two
3 10 8
2 21 4
2 matches
Mail list logo