Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 data.frames 列表,其中一些填充了 NA,我想删除列表中只有 NA 的那些 data.frames。
我正在使用这两个命令:
list.df <- lapply(list.df, na.omit) list.df <- list.df[sapply(list.df, function(x) dim(x)[1] >0 )]
有没有办法在一条线上做同样的事情?
这会保留所有data.frame至少有一个NA-free 行的 s:
data.frame
NA
df.list[ sapply( df.list, function(x){ any( rowSums(is.na(x)) == 0 ) }) ]