sample_n: Samples n shapes on Momocs objects

Description Usage Arguments See Also Examples

View source: R/cl-handling.R

Description

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

Usage

1
sample_n(tbl, size, replace, fac, ...)

Arguments

tbl

a Momocs object (Coo, Coe)

size

numeric how many shapes should we sample

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_n and to maintain generic compatibility

See Also

Other handling functions: arrange, at_least, chop, combine, dissolve, filter, mutate, rename, rm_uncomplete, rw_fac, sample_frac, select, slice, subset.Coo, transmute

Examples

1
2
3
4
5
6
7
8
data(bot)
bot
# samples 5 bottles no matter their type
sample_n(bot, 5)
# 5 bottles of beer and of whisky
table(sample_n(bot, 5, fac="type"))
# many repetitions
table(names(sample_n(bot, 400, replace=TRUE)))

Momocs documentation built on May 20, 2017, 3:10 a.m.

Search within the Momocs package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.