draw {simFrame}R Documentation

Draw a sample

Description

Generic function for drawing a sample.

Usage

draw(x, setup, ...)

## S4 method for signature 'data.frame, SampleSetup':
draw(x, setup, i = 1)

## S4 method for signature 'data.frame,
##   VirtualSampleControl':
draw(x, setup)

Arguments

x the data to sample from.
setup an object of class "SampleSetup" containing previously set up samples, a control object inheriting from the virtual class "VirtualSampleControl" or a character string specifying such a control class (the default being "SampleControl").
i an integer specifying which one of the previously set up samples should be drawn.
... if setup is a character string or missing, the slots of the control object may be supplied as additional arguments.

Value

A data.frame containing the sampled observations. In addition, the column ".weight", which consists of the sample weights, is added to the data.frame.

Author(s)

Andreas Alfons, alfons@statistik.tuwien.ac.at

See Also

setup, SampleSetup, SampleControl, VirtualSampleControl

Examples

data(eusilc)

## simple random sampling
draw(eusilc[, c("id", "eqIncome")], size = 20)

## group sampling
draw(eusilc[, c("hid", "id", "eqIncome")], 
    group = "hid", size = 10)

## stratified sampling
draw(eusilc[, c("id", "region", "eqIncome")], 
    design = "region", size = c(2, 5, 5, 3, 4, 5, 3, 5, 2))

[Package simFrame version 0.1.1 Index]