Error when using lubridate arithmetic in if_else loop
chris-nunn opened this issue · comments
Error in mutate():
i In argument:start = if_else(month == "dec", start - years(1), start)
.
Caused by error invec_ptype_common()
:
! Columnsecond
(size 432) must match the data frame (size 1).
i In file slice.c at line 191.
i Install the winch package to get additional debugging info the next time you get this error.
i This is an internal error that was detected in the vctrs package.
Please report it at https://github.com/r-lib/vctrs/issues with a reprex and the full backtrace.
This is the backtrace:
x
- +-... %>% ...
- +-dplyr::mutate(...)
- +-tidyr::pivot_longer(., future_suitability:historical)
- +-dplyr::rename(., future_suitability = value)
- +-dplyr::mutate(...)
- +-dplyr:::mutate.data.frame(., start = if_else(month == "dec", start - years(1), start))
- | -dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
- | +-base::withCallingHandlers(...)
- | -dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
- | -mask$eval_all_mutate(quo)
- | -dplyr (local) eval()
- +-dplyr::if_else(month == "dec", start - years(1), start)
- | -dplyr:::vec_case_when(...)
- | -vctrs::vec_ptype_common(!!!everything, .ptype = ptype, .call = call)
- -rlang:::stop_internal_c_lib(...)
- -rlang::abort(message, call = call, .internal = TRUE, .frame = frame)`
start, the variable being acted on, was not a date