make_samples: Generate samples from a dataset

View source: R/make_samples.r

make_samplesR Documentation

Generate samples from a dataset

Description

Generate samples of a dataset.

Usage

make_samples(
  data,
  n_samples,
  p,
  var_to_stratify = NULL,
  pond = NULL,
  seed = 12
)

Arguments

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.

Value

A list with dataframes.

Examples


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)


octmedina/ksnet documentation built on April 18, 2023, 3:34 p.m.