by-sample | R Documentation |
A data frame is split according to some variables in a formula, and a sample of a certain fraction of each is drawn.
sample_by(data, formula, frac = 0.1, replace = FALSE, systematic = FALSE)
sampleBy(
formula,
frac = 0.1,
replace = FALSE,
data = parent.frame(),
systematic = FALSE
)
data |
A data frame. |
formula |
A formula defining the grouping of the data frame. |
frac |
The part of data to be sampled. |
replace |
Is the sampling with replacement. |
systematic |
Should sampling be systematic. |
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.
A dataframe.
orderBy
, order_by
,
splitBy
, split_by
,
summaryBy
, summary_by
,
transformBy
, transform_by
data(dietox)
sampleBy(formula = ~ Evit + Cu, frac=.1, data = dietox)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.