Reprex try-out, applied Epi course EPIET fellow

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

Currently learning how to reprex and being part of this amazing community. Thanks to all who helps with all kinds of issues. → Issue using ymd

install and load packages

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

import data

surv_raw ← data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
date of report = c(“11/9/2014”,“10/31/2014”,
“8/20/2014”,“8/30/2014”,
“10/21/2014”),
onset date = c(“11/9/2014”,“10/30/2014”,
“8/16/2014”,“8/29/2014”,
“10/20/2014”),
adm3_name_res = c(NA,“Mountain Rural”,
“Mountain Rural”,“East II”,
“West III”),
sex = c(“m”, “f”, “f”, “f”, “f”)
)# clean the surveillance data

try to convert column to class “Date”

surv_clean ← surv_raw %>%
clean_names() %>%
mutate(onset_date = ymd(onset_date))

Kind regards,

Kevin Wassing

Hello,

The onset date variable in your data has the following format: mm/dd/yyyy. However, in your mutate function, you use the ymd function which does not match the aforementioned date format. Instead, you should use the mdy function and this should solve your issues.

All the best,

Tim

1 Like