| compact | R Documentation |
Remove every NULL element of .x, keeping the rest (including other
falsy-but-not-NULL values like NA, 0, or ""). The common companion
to map() when some calls legitimately return nothing – e.g. an empty
API response – and the NULLs must be dropped before foldr(),
rbindfill(), or similar.
compact(.x)
.x |
A list. |
.x with its NULL elements removed.
compact(list(1, NULL, 2, NULL, 3))
compact(list(a = 1, b = NULL, c = NA))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.