I'm trying to convert two specific columns from %d-%m-%Y %H:%M:%S to just %d-%m-%Y but when I apply this code:
# Step 6.5: Change datetime format of date columns to date only
dfTranformedWithEmployeeProfile %>%
mutate(across(c("Survey Sent Date", "Respondent Submission Date"), ~ as.Date(., format("%m/%d/%Y"))))
I get the following error:
1: Problem while computing `..1 = across(...)`.
i unknown timezone '%m/%d/%Y'
2: Problem while computing `..1 = across(...)`.
i unknown timezone '%m/%d/%Y'
in which the column in question has all of its values replaced with NA.
this is the dataframe:
tibble::tribble(
~Survey.Sent.Date, ~Respondent.Submission.Date,
NA, "08/08/2022",
NA, "04/08/2022",
NA, "04/08/2022",
NA, "04/08/2022"
)
#> # A tibble: 4 × 2
#> Survey.Sent.Date Respondent.Submission.Date
#> <lgl> <chr>
#> 1 NA 08/08/2022
#> 2 NA 04/08/2022
#> 3 NA 04/08/2022
#> 4 NA 04/08/2022
Created on 2022-09-15 by the reprex package (v2.0.1)
tibble::tribble(
~Survey.Sent.Date, ~Respondent.Submission.Date,
NA, "08/08/2022",
NA, "04/08/2022",
NA, "04/08/2022",
NA, "04/08/2022"
)
How I want it
#> # A tibble: 4 × 2
#> Survey.Sent.Date Respondent.Submission.Date
#> <lgl> <chr>
#> 29/07/2022 08/08/2022
#> 29/07/2022 04/08/2022
#> 29/07/2022 04/08/2022
#> 29/07/2022 04/08/2022
what is causing this problem and how do I fix it. I have tried using
dfTranformedWithEmployeeProfile$
Survey Sent Date
<- lubridate::mdy_hms(dfTranformedWithEmployeeProfile$Survey Sent Date
, tz="Europe/London")
to fix this but it doesn't change anything.