I am considering the below data frame as an example to sort the data frame by columns. I want to sort the column 'd' in a descending manner and column 'b' in an ascending order.
data <- data.frame(b = factor(c("Hey", "Medium", "Hey", "Low"),
levels = c("Low", "Medium", "Hey"), ordered = TRUE),
x = c("W", "Z", "W", "Y"), y = c(7, 4, 8, 8),
d = c(2, 2, 2, 3))
data
b x y d
1 Hey W 7 2
2 Medium Z 4 2
3 Hey W 8 2
4 Low Y 8 3