How to apply dplyr filter to list of data frames?

后端 未结 1 697
一整个雨季
一整个雨季 2020-12-24 14:37

I have a list() of dataframes. I want to apply dplyr\'s filter() to all of them.

Example code of what I have tried so far...

1条回答
  •  礼貌的吻别
    2020-12-24 14:53

    Using purrr

    library(purrr)
    map(list.DFs, ~filter(.x, Gold.fish.count == "Total"))
    

    Obviously, you can do exactly the same with lapply:

    lapply(list.DFs, function(x) filter(x, Gold.fish.count == "Total"))
    

    0 讨论(0)
提交回复
热议问题