Hi all, I’m attempting to clean my date column and data is getting converted to NA. Anyone know how to resolve or have experience with this troubleshooting? Thanks!
Reprex #2
#install and load packages
pacman::p_load(rio, here, janitor, datapasta, reprex, tidyverse)
#import data
surv_raw ← data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
onset date
= c(“11/9/2014”,“10/30/2014”,
“8/16/2014”,“8/29/2014”,“10/20/2014”),
age = c(23L, 1L, 16L, 10L, 0L)
)
#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 range
class(surv_clean$onset_date)
#> [1] “Date”
range(surv_clean$onset_date)
#> [1] NA NA