I would like to multiply a data frame for n rows that are grouped by a variable and sorted in descending order by another variable. This will be seen in the example:
d1 <- data.frame(Gender = c("M", "M", "F", "F", "M", "M", "F", "F"), Age = c(15, 38, 17, 35, 26, 24, 20, 26))
I would like to get 2 rows that are sorted in descending order by Age, for each field. Desired Result:
Gender Age F 35 F 26 M 38 M 26
I was looking for order, sorting and other solutions here, but could not find a suitable solution to this problem. I appreciate your help.
karlos
source share