Learn R Programming

doBy (version 1.5)

sampleBy: Sampling from a data frame

Description

A data frame is split according to some variables in a formula, and a sample of a certain fraction of each is drawn.

Usage

sampleBy(formula, frac = 0.1, replace=FALSE, data = parent.frame(),systematic=FALSE)

Arguments

formula
A formula defining the grouping of the data frame
frac
The part of data to be sampled.
replace
Is the sampling with replacement
data
A data frame
systematic
Should sampling be systematic.

Value

  • A data frame

Details

If systematic=FALSE (default) then frac gives the fraction of data sampled. If systematic=TRUE and frac=.2 then every 1/.2 i.e. every 5th observation is taken out.

References

~put references to the literature/web site here ~

See Also

See also splitBy

Examples

Run this code
data(dietox)
sampleBy(formula = ~Evit+Cu, frac=.1, data = dietox)

Run the code above in your browser using DataLab