# NOT RUN {
library(metan)
library(tibble)
df <-
tibble(y = rnorm(5),
x1 = c(1:5),
x2 = c(TRUE, TRUE, FALSE, FALSE, FALSE),
x3 = letters[1:5],
x4 = as.factor(x3))
df
# Convert y to integer
as_integer(df, y)
as_integer(df$y)
# convert x3 to factor
as_factor(df, x3)
# Convert all columns to character
as_character(df, everything())
# Convert x2 to numeric and coerce to a vector
as_numeric(df, x2, .keep = "used", .pull = TRUE)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab