Use*_*ame 12 r list dataframe dplyr
我有一个list()数据帧.我想申请dplyr的filter()于所有的人.
到目前为止我尝试过的示例代码...
require(dplyr)
list.DFs <- list(df1,df2)
lapply(
X = list.DFS,
FUN = filter(Gold.fish.count=="Total")
)
Run Code Online (Sandbox Code Playgroud)
但是这给出了一个错误:Object 'Gold.fish.count' not found.
yee*_*dle 19
运用 purrr
library(purrr)
map(list.DFs, ~filter(.x, Gold.fish.count == "Total"))
Run Code Online (Sandbox Code Playgroud)
显然,你可以用lapply做同样的事情:
lapply(list.DFs, function(x) filter(x, Gold.fish.count == "Total"))
Run Code Online (Sandbox Code Playgroud)