Skip to contents

This function searches a list and returns the index of the first non-null element.

Usage

first_non_null_index(lst)

Arguments

lst

The list to search.

Value

The index of the first non-null element, or NULL if no non-null element is found.

Examples

my_list <- list(NULL, NULL, 3, 5, NULL)
first_non_null_index(my_list)  # Returns 3
#> [1] 3