library(contrastable)
data.frame(v1 = c('a','b','c')) |>
dplyr::group_by(v1) |>
contrastable::enlist_contrasts(v1 ~ treatment_code)
Converting to factors: v1
Error in `dplyr::mutate()`:
! Problem while computing `..1 = dplyr::across(dplyr::all_of(which_to_factors), factor)`.
ℹ The error occurred in group 0: character(0).
Caused by error in `across()`:
! Can't subset columns that don't exist.
✖ Column `v1` doesn't exist.
Error from the internal mutate call comes from attempting to set contrasts on a grouping column in a dataframe. Options to fix:
Force ungroup on the dataframe before passing to mutate, add message that this is happening
Add more helpful error message telling user to ungroup the factors they're attempting to set contrasts to
Drop grouping columns that the user is trying to set, but keep grouping columns not involved in contrast functions (less overbearing but more involved than just ungroup)
Force ungroup before passing to mutate, but then regroup after applying contrasts (needs intermediate step to save grouping column names)
Error from the internal
mutate
call comes from attempting to set contrasts on a grouping column in a dataframe. Options to fix:ungroup
on the dataframe before passing tomutate
, add message that this is happeningungroup
)ungroup
before passing tomutate
, but then regroup after applying contrasts (needs intermediate step to save grouping column names)