6
Suppose a data.frame with numerical values and strings:
set.seed(1)
dados <- data.frame(w=rep(c("A", "B"), 2), x= rep(c("D", "C"), 2), y= rnorm(4), z=rnorm(4),
stringsAsFactors=FALSE)
dados
w x y z
1 A D -0.6264538 0.3295078
2 B C 0.1836433 -0.8204684
3 A D -0.8356286 0.4874291
4 B C 1.5952808 0.7383247
How do I sort the data.frame by a column? And how do I order with more than one column, and each with different orders (some in ascending order, others in descending order)?
For you to see how you can always learn even in simple things, did not know that the
decreasing
accepted vectors!– Carlos Cinelli