I am rerunning my code from more than one year ago, which tries to create an hms variable based on another character variable in the dataset. But I now get an error saying:
Error in
mutate()
:
In argument:x.time = case_when(x == "a few minute" ~ hms(minutes = 5), TRUE ~ as_hms(x))
.
Caused by error incase_when()
:
! Failed to evaluate the right-hand side of formula 2.
Caused by error inabort_lossy_cast()
:
! Lossy cast from to at position(s) 1, 2
Backtrace:
- df.test %>% ...
- hms:::as_hms.default(x)
- vctrs::vec_cast(x, new_hms())
- vctrs (local)
<fn>
()- hms:::vec_cast.hms.character(...)
- hms:::abort_lossy_cast(x, to, ..., lossy = lossy)
Below is an example code gets the same error:
df.test <- data.frame(x = c("a few minute", "1"))
df.test <- df.test %>% mutate(x.time = case_when(x == "a few minute" ~ hms(minutes = 5), TRUE ~ as.hms(x)))
I am guessing this is caused by the update of the package and I probably was using an older version that made the code work. What can I do to fix the error under v1.1.3?