order by r data frame code example
Example 1: r sort data frame by one column
population[order(population$age),]
Example 2: sort in descending order in r
#sort by mpg (ascending) and cyl (descending)
newdata <- mtcars[order(mpg, -cyl),]
population[order(population$age),]
#sort by mpg (ascending) and cyl (descending)
newdata <- mtcars[order(mpg, -cyl),]