Skip to contents

Cast variables of one type to another

Usage

cast(df, type_from, type_to, vars = NULL)

Arguments

df

data.frame

type_from

original type (a class from base::inherits())

type_to

new type (from calling as.*)

vars

(character) vector of variable names to change if they are of type type_from (if NULL, use all)

Value

data.frame with types changed

Examples

if (FALSE) {
df |>
   cast("numeric", "factor") |>
   get_desc_table(c("Age", "Nationality"), tbl_fn=tbl_fn_fac)
}