Create an rvec that uses the same value for every element and every draw.
Usage
new_rvec_chr(length = 0, n_draw = 1000, value = "")
new_rvec_dbl(length = 0, n_draw = 1000, value = 0)
new_rvec_int(length = 0, n_draw = 1000, value = 0L)
new_rvec_lgl(length = 0, n_draw = 1000, value = FALSE)Details
value must be an atomic vector of length 1.
Matrices, arrays, lists, and rvecs are not allowed.
Values are coerced to the correct type, when the
coercion can be done without losing information.
Character values are not converted to numeric
or logical values.
The defaults for value are
new_rvec_chr():""new_rvec_dbl():0new_rvec_int():0new_rvec_lgl():FALSE
See also
rvec(),rvec_chr(),rvec_dbl(),rvec_int(),rvec_lgl()Create an rvec from data.n_draw()Query number of draws.
Examples
new_rvec_int()
#> <rvec_int<1000>[0]>
new_rvec_lgl(length = 1, n_draw = 5)
#> <rvec_lgl<5>[1]>
#> [1] p=0
new_rvec_dbl(length = 2, n_draw = 5, value = NA)
#> <rvec_dbl<5>[2]>
#> [1] NA (NA, NA) NA (NA, NA)
new_rvec_int(length = 3, n_draw = 5, value = 2)
#> <rvec_int<5>[3]>
#> [1] 2 (2, 2) 2 (2, 2) 2 (2, 2)
x <- new_rvec_dbl(length = 2)
x[1] <- rnorm_rvec(n = 1, n_draw = 1000)
x[2] <- runif_rvec(n = 1, n_draw = 1000)