Learn R Programming

teal.slice (version 0.5.1)

coalesce_r: Recursively coalesce list elements.

Description

Returns first element of list that it not NULL, recursively.

Usage

coalesce_r(x)

Value

Either an atomic vector of length 1 or a (potentially nested) list.

Arguments

x

(list), either of atomic vectors or of named lists

Details

Given a list of atomic vectors, the first non-null element is returned. Given a list of lists, for all names found in all elements of the list the first non-null element of a given name is returned.

This function is used internally in c.teal_slices to manage teal_slices attributes.