Learn R Programming

vctrs (version 0.6.5)

list_drop_empty: Drop empty elements from a list

Description

list_drop_empty() removes empty elements from a list. This includes NULL elements along with empty vectors, like integer(0). This is equivalent to, but faster than, vec_slice(x, list_sizes(x) != 0L).

Usage

list_drop_empty(x)

Arguments

x

A list.

Dependencies

  • vec_slice()

Examples

Run this code
x <- list(1, NULL, integer(), 2)
list_drop_empty(x)

Run the code above in your browser using DataLab