根据每个数据框中的观察数量过滤数据框列表 [英] Filtering list of dataframes based on the number of observations in each dataframe
本文介绍了根据每个数据框中的观察数量过滤数据框列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设您有数据框列表:
library(tidyverse)
library(janitor)
dat <- map(mtcars, tabyl)
然后你怎么能过滤掉那些超过 6 个观察值的数据框?
How could you then filter out those dataframes with more than 6 observations?
我的第一个想法是 discard()
但我没有这样的运气.任何见解将不胜感激!
My first thought was discard()
but I have had no such luck. Any insight would be appreciated!
推荐答案
With purrr::discard
purrr::discard(dat, ~nrow(.) < 6)
或使用 keep
purrr::keep(dat, ~nrow(.) >= 6)
这篇关于根据每个数据框中的观察数量过滤数据框列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文