If I want to convert an integer or double variables to character variables, how can I accomplish the task, I tried the below code, but I a
integer
double
character
We can do this with base R
base R
storms[] <- lapply(storms, function(x) if(is.numeric(x)) as.character(x) else x)
Or using data.table
data.table
library(data.table) setDT(storms)[, names(storms) := lapply(.SD, function(x) if(is.numeric(x)) as.character(x) else x)]