Answers for "sort in descending order in r"

R
4

sort in descending order in r

library(dplyr)
set.seed(1234)
data_frame <- tibble(  
	c1 = rnorm(50, 5, 1.5),   
	c2 = rnorm(50, 5, 1.5),  
	c3 = rnorm(50, 5, 1.5),
	c4 = rnorm(50, 5, 1.5), 	
	c5 = rnorm(50, 5, 1.5)
)
# Sort by c1
df <-data_frame[order(data_frame$c1),]
head(df)
Posted by: Guest on September-09-2020
1

sort in descending order in r

#sort by mpg (ascending) and cyl (descending)
newdata <- mtcars[order(mpg, -cyl),]
Posted by: Guest on September-09-2020

Code answers related to "sort in descending order in r"

Browse Popular Code Answers by Language