Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

new-vector

Create vectors matching a given length


Description

Questioning lifecycle

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.

Usage

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)

Arguments

n

The vector length.

names

Names for the new vector.

Lifecycle

These functions are likely to be replaced by a vctrs equivalent in the future. They are in the questioning lifecycle stage.

See Also

rep_along

Examples

new_list(10)
new_logical(10)

rlang

Functions for Base Types and Core R and 'Tidyverse' Features

v0.4.11
MIT + file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], mikefc [cph] (Hash implementation based on Mike's xxhashlite), Yann Collet [cph] (Author of the embedded xxHash library), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.