Raw data is usually not completely ready for analysis, and needs to
be cleaned up to certain standards. For example, some data operations
require that the input does not include NULL
values in any
level, therefore fun = "is.null"
and recursive = TRUE
can be useful to clean out all NULL
values in a list at any
level.
Sometimes, not only NULL
values are undesired,
empty vectors or lists are also unwanted. In this case,
fun = function(x) length(x) == 0L
can be useful to remove
all empty elements of zero length. This works because
length(NULL) == 0L
, length(list()) == 0L
and
length(numeric()) == 0L
are all TRUE
.