draws_fun {rvec} | R Documentation |
Apply Summary Function Across Random Draws
Description
Summarise the distribution of random draws
in an rvec
, using a function.
Usage
draws_fun(x, fun, ...)
## S3 method for class 'rvec'
draws_fun(x, fun, ...)
Arguments
x |
An object of class rvec. |
fun |
A function. |
... |
Additional arguments passed to |
Value
The results from calls to fun
,
combined using vctrs::vec_c()
.
See Also
Apply pre-specified functions across draws:
Examples
set.seed(0)
m <- rbind(a = rnorm(100, mean = 5, sd = 2),
b = rnorm(100, mean = -3, sd = 3),
c = rnorm(100, mean = 0, sd = 20))
x <- rvec(m)
x
draws_fun(x, fun = mad)
draws_fun(x, fun = range)
draws_fun(x, weighted.mean, wt = runif(100))
draws_fun(x, function(x) sd(x) / mean(x))
[Package rvec version 0.0.6 Index]