factor_modify: Create or modify factor in the modeling dataset

View source: R/factor_modify.R

factor_modifyR Documentation

Create or modify factor in the modeling dataset

Description

Modifies one or more factors in the modeling dataset. Predictors in the model formula can also be modified directly.

Usage

factor_modify(setup, ...)

Arguments

setup

Setup object. Created at the start of the workflow. Usually piped in from previous step.

...

Expression. One or more named expressions (similar to dplyr::mutate).

Value

Setup object with updated attributes.

See Also

custom_factor, variate, as_simple_factor, offset

Examples

require(dplyr) # for the pipe operator
data('sev_train')

setup <- setup(
  data_train = sev_train,
  target = 'sev',
  weight = 'numclaims',
  family = 'gamma',
  keep_cols = c('pol_nbr', 'exposure', 'premium')
)

modeling <- setup %>%
  factor_add(pol_yr) %>%
  factor_add(agecat) %>%
  model_fit() %>%
  model_save('model1') %>%
  factor_modify(agecat = variate(agecat, type = 'non_prop', mapping = c(1, 2, 3, 4, 5, 6))) %>%
  model_fit()


realgabon/insuRglm documentation built on Jan. 2, 2023, 2:51 a.m.