Learn R Programming

Momocs (version 1.2.9)

sample_frac: Sample a fraction of shapes

Description

Sample a fraction of shapes from a Momocs object. See examples and ?dplyr::sample_n.

Usage

sample_frac(tbl, size, replace, fac, ...)

Arguments

tbl

a Momocs object (Coo, Coe)

size

numeric (0 < numeric <= 1) the fraction of shapes to select

replace

logical whether sample should be done with ot without replacement

fac

a column name if a $fac is defined; size is then applied within levels of this factor

...

additional arguments to dplyr::sample_frac and to maintain generic compatibility

See Also

Other handling functions: arrange, at_least, chop, combine, dissolve, fac_dispatcher, filter, mutate, rescale, rm_harm, rm_uncomplete, rw_fac, sample_n, select, slice

Examples

Run this code
# NOT RUN {
# samples 50% of the bottles no matter their type
sample_frac(bot, 0.5)
# 80% bottles of beer and of whisky
table(sample_frac(bot, 0.8, fac="type")$fac)
# bootstrap the same number of bootles of each type but with replacement
table(names(sample_frac(bot, 1, replace=TRUE)))

# }

Run the code above in your browser using DataLab