我有一个数据框list()
。我想将dplyr
的filter()
应用于所有这些。
到目前为止我尝试过的示例代码...
require(dplyr)
list.DFs <- list(df1,df2)
lapply(
X = list.DFS,
FUN = filter(Gold.fish.count=="Total")
)
但这会产生错误:
Object 'Gold.fish.count' not found
。
最佳答案
使用purrr
library(purrr)
map(list.DFs, ~filter(.x, Gold.fish.count == "Total"))
显然,您可以对lapply执行完全相同的操作:
lapply(list.DFs, function(x) filter(x, Gold.fish.count == "Total"))
关于r - 如何将dplyr过滤器应用于数据帧列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42883728/