rlang (version 0.0.0.9000)

new-vectors: Create new vectors.

Description

These functions construct vectors of given length, with attributes specified via dots. Except for new_lst() and new_raw(), the empty vectors are filled with typed missing values. This is in contrast to the base function vector() which creates zero-filled vectors.

Usage

new_lgl(.n = 0, ..., .attrs = list())
new_int(.n = 0, ..., .attrs = list())
new_dbl(.n = 0, ..., .attrs = list())
new_chr(.n = 0, ..., .attrs = list())
new_lst(.n = 0, ..., .attrs = list())
new_cpl(.n = 0, ..., .attrs = list())
new_raw(.n = 0, ..., .attrs = list())

Arguments

.n
The vector length.
...
A list of named attributes.
.attrs
A list of named attributes.

See Also

along

Examples

Run this code
new_lst(10)

# Add attributes, including the S3 class:
new_int(0, index = 1)
new_dbl(10, class = "my_class")

Run the code above in your browser using DataLab