These functions construct vectors of a given length, with attributes
specified via dots. Except for new_list()
and new_raw()
, the
empty vectors are filled with typed missing values. This is in
contrast to the base function base::vector()
which creates
zero-filled vectors.
new_logical(n, names = NULL)
new_integer(n, names = NULL)
new_double(n, names = NULL)
new_character(n, names = NULL)
new_complex(n, names = NULL)
new_raw(n, names = NULL)
new_list(n, names = NULL)
The vector length.
Names for the new vector.
These functions are likely to be replaced by a vctrs equivalent in the future. They are in the questioning lifecycle stage.
rep_along
new_list(10)
#> [[1]]
#> NULL
#>
#> [[2]]
#> NULL
#>
#> [[3]]
#> NULL
#>
#> [[4]]
#> NULL
#>
#> [[5]]
#> NULL
#>
#> [[6]]
#> NULL
#>
#> [[7]]
#> NULL
#>
#> [[8]]
#> NULL
#>
#> [[9]]
#> NULL
#>
#> [[10]]
#> NULL
#>
new_logical(10)
#> [1] NA NA NA NA NA NA NA NA NA NA