| rnorm_from {cheem} | R Documentation |
Draw new samples from the supplied data given its mean and covariances.
Description
Creates new observation of the data given its specific means and shapes. typically applied to a cluster subset of data. ie draw from cluster 'a', then assign to cluster 'b'.
Usage
rnorm_from(
data,
n_obs = 1,
var_coeff = 1,
method = c("pearson", "kendall", "spearman")
)
Arguments
data |
A data.frame or matrix to sample from. |
n_obs |
Number of new observations to draw. Defaults to 1. |
var_coeff |
Variance coefficient, closer to 0 make points near the median, above 1 makes more points further away from the median. Defaults to 1. |
method |
The method of the covariance matrix. Expects "person" (continuous numeric), "kendall" or "spearman" (latter two are ranked based ordinal). |
Value
A data.frame, sampled observations given the means and covariance of the data based on with column names kept.
See Also
Other cheem utility:
as_logical_index(),
color_scale_of(),
contains_nonnumeric(),
is_discrete(),
is_diverging(),
linear_tform(),
logistic_tform(),
problem_type(),
sug_basis(),
sug_manip_var()
Examples
library(cheem)
sub <- mtcars[mtcars$cyl == 6, ]
## Draw 3 new observations in the shape of 6 cylinder vehicles, with reduced variance.
rnorm_from(data = sub, n_obs = 3, var_coeff = .5)