How to sort all dataframes in a list of dataframes on the same column?

后端 未结 3 1483
后悔当初
后悔当初 2020-12-06 13:25

I have a list of dataframes dataframes_list. For an example, I put the dput(dataframes_list) at the bottom. I want to sort all dataframes in the li

3条回答
  •  执念已碎
    2020-12-06 13:51

    lapply is your friend ;)

    You could do it using arrange from dplyr pacakge like this:

    library(dplyr)
    newlist <- lapply(dataframeslist, function(df){arrange(df,enrichment)})
    

    or without dplyr like this:

    newlist <- lapply(dataframeslist, function(df){df[order(df$enrichment),]})
    

提交回复
热议问题