sample_frac | R Documentation |
Sample a fraction of shapes from a Momocs object. See examples and ?dplyr::sample_n
.
sample_frac(tbl, size, replace, fac, ...)
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 |
... |
additional arguments to dplyr::sample_frac and to maintain generic compatibility |
a Momocs object of same class
the resulting fraction is rounded with ceiling.
Other handling functions:
arrange()
,
at_least()
,
chop()
,
combine()
,
dissolve()
,
fac_dispatcher()
,
filter()
,
mutate()
,
rename()
,
rescale()
,
rm_harm()
,
rm_missing()
,
rm_uncomplete()
,
rw_fac()
,
sample_n()
,
select()
,
slice()
,
subsetize()
# 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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.