I was following the clue: Mutate and format multiple date columns
The solution results in an error
M601_M_multi.2 <- M601_M_multi %>%
mutate (
across(ends_with(' Time'), ~format(as.POSIXct(.), "%d.%m.%Y %H:%M:%S")),
.names = "{.col}.used")
)
Error in `mutate()`:
ℹ In argument: `across(contains(" Time"), ~format(as.POSIXct(.), "%d.%m.%Y %H:%M:%S"))`.
Caused by error in `across()`:
! Can't compute column `C3_S1_O2_PV Time`.
Caused by error in `as.POSIXlt.character()`
In df I have numerous columns where the name ends with " Time". I want to convert all to date and time (as.POSIXct)
The single column solution works though
M601_M_multi.2 <- M601_M_multi %>%
mutate (
test = as.POSIXct(`C3_S1_O2_PV Time`, format ="%d.%m.%Y %H:%M:%S")
)
Any suggestion and answer will be appreciated