It can be useful to create an empty list that you plan to fill later. This is similar to the idea of seq_along(), which creates a vector of the same length as its input.

list_along(x)

Arguments

x A vector.

Value

A list of the same length as x.

Details

This function might change to vctrs::vec_init().

Examples

x <- 1:5
seq_along(x)#> [1] 1 2 3 4 5list_along(x)#> [[1]]
#> NULL
#>
#> [[2]]
#> NULL
#>
#> [[3]]
#> NULL
#>
#> [[4]]
#> NULL
#>
#> [[5]]
#> NULL
#>