cb_apply_col_spec()
applies column definitions contained in a col_spec
object (typically created using readr::cols()
), to the chosen columns in a
data.frame
.
NOTE: This is currently only implemented for column specifications specifying conversion to a factor variable.
Usage
cb_apply_col_spec(
d,
cspec,
warn_missing_levels = TRUE,
set_spec_attribute = FALSE,
set_problems_attribute = TRUE
)
Arguments
- d
The
data.frame
to which thecol_spec
should be applied.- cspec
The
col_spec
to apply.- warn_missing_levels
Warn if any values in
d
don't match the levels of the corresponding factor.- set_spec_attribute
Should the
spec
attribute of the result be set to thecol_spec
(for compatibility withreadr
behavior).- set_problems_attribute
Should the
problems
attributes of the result be set in case of problems with parsing.