Hello,
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)
data
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()
.
#> 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
class(surv_clean$onset_date)
#> [1] “Date”
range(surv_clean$onset_date)
#> [1] NA NA
Created on 2024-03-12 with reprex v2.1.0