| fac_dispatcher {Momocs} | R Documentation |
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 |
fac |
a specification to extract from |
Details
fac can be:
a factor, passed on the fly
a column id from
$faca column name from
fac; if not found, returnNULLwith a messagea formula in the form:
~column_name(from$fac, no quotes). It expresses more in a concise way. Also allows interacting on the fly. See examples.a
NULLreturns aNULL, with a message
Value
a prepared factor (or a numeric). See examples
See Also
Other handling functions:
arrange(),
at_least(),
chop(),
combine(),
dissolve(),
filter(),
mutate(),
rename(),
rescale(),
rm_harm(),
rm_missing(),
rm_uncomplete(),
rw_fac(),
sample_frac(),
sample_n(),
select(),
slice(),
subsetize()
Examples
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)
# when passing NULL or non existing column
fac_dispatcher(42, NULL)
fac_dispatcher(bot, "loser")