How to get top n companies from a data frame in decreasing order

后端 未结 4 903
一向
一向 2020-12-03 08:50

I am trying to get the top \'n\' companies from a data frame.Here is my code below.

data(\"Forbes2000\", package = \"HSAUR\")
sort(Forbes2000$profits,decreas         


        
4条回答
  •  执笔经年
    2020-12-03 09:20

    Use order to sort the data.frame, then use head to get only the first 50 rows.

    data("Forbes2000", package = "HSAUR")
    head(Forbes2000[order(Forbes2000$profits, decreasing=TRUE), ], 50)
    

提交回复
热议问题