r-lib / vctrs

Generic programming with typed R vectors

Home Page:https://vctrs.r-lib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 in vec_ptype_common():
! Column second (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

  1. +-... %>% ...
  2. +-dplyr::mutate(...)
  3. +-tidyr::pivot_longer(., future_suitability:historical)
  4. +-dplyr::rename(., future_suitability = value)
  5. +-dplyr::mutate(...)
  6. +-dplyr:::mutate.data.frame(., start = if_else(month == "dec", start - years(1), start))
  7. | -dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
  8. | +-base::withCallingHandlers(...)
  9. | -dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
  10. | -mask$eval_all_mutate(quo)
  11. | -dplyr (local) eval()
  12. +-dplyr::if_else(month == "dec", start - years(1), start)
  13. | -dplyr:::vec_case_when(...)
  14. | -vctrs::vec_ptype_common(!!!everything, .ptype = ptype, .call = call)
  15. -rlang:::stop_internal_c_lib(...)
  16. -rlang::abort(message, call = call, .internal = TRUE, .frame = frame)`

start, the variable being acted on, was not a date