r - Rank each row in a data frame in descending order -
I want to apply rank by in each row in a data frame Am (data.frame, 1, rank) . However, Rank is ascending by default. So when I apply ranks () to my first line with values (2,1,3,5), then I
[1] 2 1 3 4 However, I should
[1] 3 4 2 1 How can I do this? Data.frame, 1, rank) ?
Try
< P>
# [1] 2 1 3 4 rank (-v1) # [1] 3 4 2 1
data Set.seed (24) data & lt; - as.data.frame (matrix (sample (1:20, 4 * 20, space = TRUE), ncol = 4))
Set.seed (24) data & lt; - as.data.frame (matrix (sample (1:20, 4 * 20, space = TRUE), ncol = 4))
Comments
Post a Comment