Say you have the following data set.
df1<-matrix(data = 1:10,
nrow = 5,
ncol = 5)
colnames(df1)=c("a","b","c","d","e")
How would you extract the top X values from each individual column as a new data frame?
The expected output would be something like this (for the top 3 values in each column
| a | b | c | d | e |
|---|---|---|---|---|
| 5 | 10 | 5 | 10 | 5 |
| 4 | 9 | 4 | 9 | 4 |
| 3 | 8 | 3 | 8 | 3 |