Unexpected NA values in date column


I am an epidemiologist supporting an Ebola response. I tried to clean my date column, but all the values were converted to NA and I am not sure why. I tried looking in the Epi R handbook but could not figure it out. Any help greatly appreciated.
Reprex below:

install and load packages

pacman::p_load(rio, janitor, tidyverse, datapasta, reprex)


surv_raw ← data.frame(
stringsAsFactors = FALSE,
case_id = c(“694928”,“86340d”,“92d002”,“544bd1”,“6056ba”),
sex = c(“m”, “f”, “f”, “f”, “f”),
onset_date = c(“11/9/2014”,“10/30/2014”,“8/16/2014”,“8/29/2014”,“10/20/2014”)

try to convert column to class “Date”

surv_clean ← surv_raw %>%
clean_names() %>%
mutate(onset_date = ymd(onset_date))

check the CLEANED date column class and date range


1 Like


Please see the following thread for an answer to the exact problem: Exercise for R Training course: Unexpected NA value in date column - #2 by machupovirus

All the best,