ys_add_factors | R Documentation |
Add factors to data set based on spec information
ys_add_factors(
.data,
.spec,
...,
.all = TRUE,
.missing = NULL,
.suffix = getOption("ys.fct.suffix", "_f")
)
yspec_add_factors(
.data,
.spec,
...,
.all = TRUE,
.missing = NULL,
.suffix = getOption("ys.fct.suffix", "_f")
)
ys_make_factor(values, x, strict = TRUE, .missing = NULL)
yspec_make_factor(values, x, strict = TRUE, .missing = NULL)
.data |
the data set to modify |
.spec |
a yspec object |
... |
unquoted column names for modification; passing nothing through
|
.all |
if |
.missing |
a label to use assign to missing values |
.suffix |
used to make the column name for the factors |
values |
a vector of values to convert to a factor |
x |
a ycol object |
strict |
if 'FALSE', then a factor will be returned for any 'values' type |
Note that .suffix
can be chosen using option ys.fct.suffix
. When the
factor is made by base::factor()
, the exclude
argument is forced to
character(0)
so that nothing is excluded.
ys_factors()
spec <- load_spec_ex()
ys_make_factor(c(1,0,1,1,1,0), spec$SEX)
data <- data.frame(SEX = c(1,1,1,1,0,0,1,1), STUDY= c(202,100))
head(ys_add_factors(data, spec, SEX, STUDY))
data <- ys_help$data()
spec <- ys_help$spec()
head(ys_add_factors(data, spec))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.