cb_apply_col_spec: Apply a col_spec to a data.frame

View source: R/cb.R

cb_apply_col_specR Documentation

Apply a col_spec to a data.frame

Description

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 the col_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 the col_spec (for compatibility with readr behavior).

set_problems_attribute

Should the problems attributes of the result be set in case of problems with parsing.

Value

A data.frame based on d, with corresponding columns changed according to the values specified in cspec


torfason/zulutils documentation built on Aug. 21, 2023, 5:46 p.m.