从列表中的多个列表中删除Null [英] Remove Nulls from multiple lists in list
本文介绍了从列表中的多个列表中删除Null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个很大的SpatialPolygonsDataFrames列表(A
).一些列表具有空值(意味着没有SpatialPolygonsDataFrame).我试过了:
I have a big list (A
) of lists of SpatialPolygonsDataFrames. Some of the lists have null values (means there is no SpatialPolygonsDataFrame). I tried :
A[!sapply(unlist(A, recursive=FALSE), is.null)]
但是没有结果,然后我尝试了:
But with no result and then I tried:
A_nonulls=lapply(A, na.omit)
删除较大列表中每个列表的null的正确方法是什么?
What is the right way to remove the null of every list in the bigger list?
我无法执行str(A),因为A有1000个列表,而且列表很大.第一个列表中的第一个元素是:
I can't do str(A)because A has 1000 lists and is huge. The first elements from the first list is like :
[[1]]
NULL
[[2]]
NULL
[[3]]
NULL
[[4]]
NULL
[[5]]
class : SpatialPolygons
features : 1
extent : 722951.5, 726848.9, 4325874, 4329654 (xmin, xmax, ymin, ymax)
所以我想删除null并仅保留非空元素.
So I want to removw the nulls and keep only the not empty elements.
推荐答案
我们可以尝试Filter
Filter(Negate(is.null), A)
这篇关于从列表中的多个列表中删除Null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文