Make a table showing the 10 largest values of a variable in R?
问题 I want to make a simple table that showcases the largest 10 values for a given variable in my dataset, as well as 4 other variables for each observation, so basically a small subset of my data. It would look something like this: Score District Age Group Gender 17 B 23 Red 1 12 A 61 Red 0 11.7 A 18 Blue 0 10 B 18 Red 0 . . etc. whereby the data is ordered on the Score var. All the data is contained within the same dataframe. 回答1: This should do it... data <- data[with(data,order(-Score)),]