Checks if check_cols
exist in dt
and are of type is_fun
.
If any of check_cols
are of that type, then modifies the values using
as_fun
.
change_col_type(dt, check_cols, is_fun = is.integer, as_fun = as.numeric)
dt | |
---|---|
check_cols | [ |
is_fun | [ |
as_fun | [ |
Modifies dt
in place and returns dt
invisibly.
dt <- data.table::data.table(year = 1950L, age_start = 0L) change_col_type(dt, c("year", "year_start", "age_start"))