-Unknown NA value in date column


I am doing R intro course and I am having an issue with the onset date in the Ebola dataset. Dates are showing as NA once cleaned. Reprex is below

install and load packages

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


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))
#> Warning: There was 1 warning in mutate().
#> :information_source: In argument: onset_date = ymd(onset_date).
#> Caused by warning:
#> ! All formats failed to parse. No formats found.

check the CLEANED date column class and date range

#> [1] “Date”
#> [1] NA NA
Created on 2024-03-12 with reprex v2.1.0

1 Like


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

All the best,