| rvec {rvec} | R Documentation |
Create an Rvec
Description
Create an Object of Class "rvec".
Usage
rvec(x)
rvec_chr(x = NULL)
rvec_dbl(x = NULL)
rvec_int(x = NULL)
rvec_lgl(x = NULL)
Arguments
x |
A matrix, a list of vectors, or an atomic vector. |
Details
Class "rvec" has four subclasses, each dealing with
a diffent type:
-
"rvec_dbl"doubles -
"rvec_int"integers -
"rvec_lgl"logical -
"rvec_chr"character
These subclasses are analogous to double(),
integer(), logical(), and character()
vectors.
Function rvec() chooses the subclass, based on
x. Functions rvec_dbl(), rvec_int(),
rvec_lgl(), and rvec_chr() each create
objects of a particular subclass.
x can be
A matrix, where each row is a set of draws for an unknown quantity.
A list, where each element is a set of draws.
An atomic vector, which is treated as a single-column matrix.
Value
An rvec with the following class:
-
rvec_dbl():"rvec_dbl" -
rvec_int():"rvec_int" -
rvec_lgl():"rvec_lgl" -
rvec_chr():"rvec_chr" -
rvec():"rvec_chr","rvec_dbl""rvec_int", or"rvec_lgl", depending ontypeof(x).
See Also
-
collapse_to_rvec()creates rvecs within a data frame. Random variate functions such as
rnorm_rvec()andrbinom_rvec()can be used to create rvecs representing probability distributions.
Examples
m <- rbind(c(-1.5, 2, 0.2),
c(-2.3, 3, 1.2))
rvec_dbl(m)
l <- list(rpois(100, lambda = 10.2),
rpois(100, lambda = 5.5))
rvec(l)
rvec(letters[1:5])
l <- list(a = c(TRUE, FALSE),
b = c(FALSE, TRUE))
rvec(l)