Learn R Programming

Momocs (version 1.2.9)

fac_dispatcher: Brew and serve fac from Momocs object

Description

Ease various specifications for fac specification when passed to Momocs objects. Intensively used (internally).

Usage

fac_dispatcher(x, fac)

Arguments

x

a Momocs object (any Coo, Coe, PCA, etc.)

fac

a specification to extract from fac

Value

a prepared factor (or a numeric). See examples

Details

fac can be:

  • a factor, passed on the fly

  • a column id from $fac

  • a column name from fac

  • a formula (preferred) in the form: ~column_name (from $fac, no quotes)

See Also

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

Examples

Run this code
# NOT RUN {
bot <- mutate(bot, s=rnorm(40), fake=factor(rep(letters[1:4], 10)))

# factor, on the fly
fac_dispatcher(bot, factor(rep(letters[1:4], 10)))

# column id
fac_dispatcher(bot, 1)

# column name
fac_dispatcher(bot, "type")
# same, numeric case
fac_dispatcher(bot, "s")

# formula interface
fac_dispatcher(bot, ~type)

# formula interface + interaction on the fly
fac_dispatcher(bot, ~type+fake)
# }

Run the code above in your browser using DataLab