Cleaning error for date column

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”,
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().
#> :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 range
#> [1] “Date”
#> [1] NA NA

1 Like


The format of your dates is connected to which lubridate function you should use. In your case, the dates have the following format: mm/dd/YYYY. This means you should use mdy and not ymd when you convert this variable to a date using lubridate functions.

All the best,


1 Like