Hi @d.honeyman, The column onset_date does not exist in surv_raw dataframe. That’s why the last line of the error message says the column is not found.
I have added a onset_date column in your example. Now, your code works. Hope this helps.
library(tidyverse)
library(janitor)
surv_raw <- data.frame(
stringsAsFactors = FALSE,
adm3_name_res = c(NA,"Mountain Rural",
"Mountain Rural","East II","West III"),
sex = c("m", "f", "f", "f", "f"),
onset_date = c("2020-01-01", "2020-01-10", "2020-01-15", "2020-01-18", "2020-01-11")
)
surv_clean <- surv_raw %>%
clean_names() %>%
mutate(onset_date = ymd(onset_date))
surv_clean
#
# adm3_name_res sex onset_date
# 1 <NA> m 2020-01-01
# 2 Mountain Rural f 2020-01-10
# 3 Mountain Rural f 2020-01-15
# 4 East II f 2020-01-18
# 5 West III f 2020-01-11