Skip to contents

Returns x unchanged if it is already a list, otherwise wraps it in a one-element list. Used internally to normalize arg inputs that may be either a single numeric vector or a list of per-curve vectors.

Usage

ensure_list(x)

Arguments

x

any input.

Value

x if it is a list, otherwise list(x).

See also

Other tidyfun utility functions: in_range(), tf_arg(), tf_zoom(), unique_id()

Examples

ensure_list(1:3)
#> [[1]]
#> [1] 1 2 3
#> 
ensure_list(list(1:3, 4:6))
#> [[1]]
#> [1] 1 2 3
#> 
#> [[2]]
#> [1] 4 5 6
#>