I am looking to apply an UDF to an entire dataframe via lapply. However, the act of doing so also coerces data in a way almost as if R wanted to dummy code the columns.
dummy data
df = data.frame(customer_id = c("c000000067", "c000678746")
,email = c("hello@gmail.com", "NULL")
)
apply function
df[] = lapply(df, function(x) ifelse(x=='NULL', NA, x)); View(df)
As one can see, both customer_id and email have had their data changed. I have in the past used lapply on selected columns with success
df[ , c('date_1', 'date_2')] = data.frame(lapply(df[ , c('date_1', 'date_2')] , FUN = function(x) as.Date(x, "%d/%m/%Y")))
However, applying over a whole dataframe seems to be failing. Thank you for your help.