View source: R/utils_compact.R
| compact_list | R Documentation |
Remove empty elements from lists
compact_list(x, remove_na = FALSE)
x |
A list or vector. |
remove_na |
Logical to decide if |
By default, compact_list() does not remove "empty" elements from
deeper list levels. Only if an element on the first level of a list is
"empty", it is removed.
compact_list(list(NULL, 1, c(NA, NA)))
compact_list(c(1, NA, NA))
compact_list(c(1, NA, NA), remove_na = TRUE)
# remove only NULL on top level, don't change deeper lists
compact_list(list(
a = 1,
NULL,
b = list(NULL, list(1, 2, 3), list(list(x = 3, y = 4, NULL))),
NULL
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.