R: sort
Revision as of 07:42, 5 November 2018 by Onnowpurbo (talk | contribs) (Created page with " # sorting examples using the mtcars dataset attach(mtcars) # sort by mpg newdata <- mtcars[order(mpg),] # sort by mpg and cyl newdata <- mtcars[order(mpg, cyl),] #so...")
# sorting examples using the mtcars dataset attach(mtcars)
# sort by mpg newdata <- mtcars[order(mpg),]
# sort by mpg and cyl newdata <- mtcars[order(mpg, cyl),]
#sort by mpg (ascending) and cyl (descending) newdata <- mtcars[order(mpg, -cyl),]
detach(mtcars)