R code reprex trial

Thank you for posting! Here is an outline of an effective post:

Describe your issue

unable to see date in my dataset after cleaning & mutate

What steps have you already taken to find an answer?

Provide an example of your R code

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](https://reprex.tidyverse.org/)

Session info

## Follow-up  
- Thank the volunteers who try to help you
- Mark one reply as the "Solution" if appropriate
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,