make_samples | R Documentation |
Generate samples of a dataset.
make_samples(
data,
n_samples,
p,
var_to_stratify = NULL,
pond = NULL,
seed = 12
)
data |
a dataframe |
n_samples |
Number of samples. |
p |
Numeric between 0 and 1. Percentage of observations to keep in each sample. |
var_to_stratify |
If desired, name of variable to straty the sampling. Default NULL. |
pond |
A numeric vector of sample weights. Default NULL. |
seed |
Numeric. |
A list with dataframes.
ecv <- read_csv('ecv.csv')
# Make 10 samples, 90% of observations in each one and stratify by CCAA
ecv_samples <- make_samples(ecv, 10, .9, 'CCAA')
# Taking into account sample weights
ecv_samples <- make_samples(ecv, 10, .9, 'CCAA', ecv$factor_hogar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.