by-sample: Sampling from a data frame

Description Usage Arguments Details Value See Also Examples

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

1
2
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.

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.

Value

A dataframe.

See Also

summaryBy, orderBy, splitBy, transformBy

Examples

1
2
data(dietox)
sampleBy(formula = ~Evit+Cu, frac=.1, data = dietox)

doBy documentation built on May 1, 2019, 6:31 p.m.