I have a following data frame
a = data.frame(a=c(1,2,3,4,5,6,7),b=c(1,2,3,10,12,21,4),c=c(1,2,10,11,\"X\",\"Y\",3)) > a a b c 1 1 1 1 2 2 2 2 3 3
One option is to use mixedorder() from the gtools package.
mixedorder()
library(gtools) a[mixedorder(a$c),] # a b c # 1 1 1 1 # 2 2 2 2 # 7 7 4 3 # 3 3 3 10 # 4 4 10 11 # 5 5 12 X # 6 6 21 Y