easystats / effectsize

:dragon: Compute and work with indices of effect size and standardized parameters
https://easystats.github.io/effectsize/
Other
331 stars 22 forks source link

Error: cannot use 'paired = TRUE' in formula method. #615

Closed Generalized closed 8 months ago

Generalized commented 8 months ago

Hi, I updated the effectsize package and my previously working code broke!

In the past I could use

with(data.frame(Value=1:20, Time=gl(2, 10)), effectsize::cohens_d(Value ~ Time, paired=TRUE))

and it worked well.

Now it says:

Error: cannot use 'paired = TRUE' in formula method.

Is this an intentional behavior? Now I need to rewrite a lot of my code... I need an urgent solution to make it working again by Monday (ideally without changing data structures, as it's all validated code)!

I found this code:

.get_data_2_samples <- function(x, y = NULL, data = NULL,
                                paired = FALSE, allow_ordered = FALSE,
                                verbose = TRUE, ...) {
  if (inherits(x, "formula")) {
    if (isTRUE(paired)) {
      # This is to be consistent with R>=4.4.0
      insight::format_error("cannot use 'paired = TRUE' in formula method.")
    }

and this:

Breaking Changes

    cohens_d(), hedges_g(), p_superiority(), wmw_odds(), means_ratio() and rank_biserial() no longer support setting paired = TRUE when using the formula method.

Oh gods, R does everything to be the nightmare for SAS and other stable software users :/

mattansb commented 8 months ago

(Duplicate of #610)

This is expected, and is consistent with the upcoming changes in R>=4.4.0 where this method will not be supported in t.test(). See https://github.com/r-devel/r-svn/pull/142.

Generalized commented 8 months ago

Thank you. I must say R is awful in what it does to users in controlled fields (like clinical trials) breaking hundreds of lines of validated code. Well, I understand the issue. Thank you for clarification.

mattansb commented 8 months ago

I suggest using package version control systems such as {renv} - that might ease your pain (:

Generalized commented 8 months ago

I already do use a package management system. The issue is that if there is an error in a package (not yours in this case), update is necessary, and update of one package may (and often needs) update of other packages too, breaking validation due to chained nature of R packages (calling other packages). Even worse, packages compiled under certain R version may already have some "features" implemented. For example I use <4.4, but numerous packages already implemented the new R "paired solution" and were compiled under 4.4. Even I can use it under 4.2, these features are already missing. So all validated code that used it, must be adapted, because bug fix required version update. It's cool when updates bring just new features, so one doesn't need to care at all. Then all package managers work like a charm under idealized conditions. It's also cool when a bugfix doesn't change much even if the version is altered and done alone. It all complicates when the updating the version brings more changes than the issue in question, needs update of other packages, and these packages also bring changes, and so on. In SAS, for example, backward compatibility in many procedures dates back '90s or earlier, in some ~2010. R is much more dynamic (especially if one uses tidyverse - convenience has a serious and painful price), which needs special measures to be taken.