Tibble 3.0 broke casen package. Error: No common type for `..1` <svyby<>> and `..2` <data.frame<>>

Viewed 95

casen package

casen:: is a package to obtain correct estimates for complex designs.

After the release of tibble 3.0 I got this email from CRAN:

Dear maintainer,

Please see the problems shown on https://cran.r-project.org/web/checks/check_results_casen.html.

The new check problems are from a recent upgrade of package 'tibble' to version 3.0.0, with breaking changes described at https://tibble.tidyverse.org/news/index.html.

We understand that you were not informed by the tibble maintainer about the upcoming breakage, and many of us currently have very little time to work on their packages. Can you nevertheless please try to fix your package as quickly as possible? If the description of the breaking changes does not suffice, please feel free to ask the tibble maintainer for help.

Please correct before 2020-04-22 to safely retain your package on CRAN.

MWE and required fix

Here's a MWE that illustrates what needs to be fixed in the package so it's not removed from CRAN:

What works

Just as inside the package, but simplified.

# packages

# devtools::install_github("pachamaltese/casen")
# or
# install.packages("casen")

library(casen)
library(dplyr)
library(purrr)
library(rlang)

# set up a complex design and variables, just as in the package

disenio <- configuracion_disenio(datos = casen_2017_los_rios,
                                 variable = "ytotcorh",
                                 agrupacion = c("comuna", "sexo"),
                                 peso = "expc")

d_groups = disenio$grupos
des = disenio$disenio
stat_fun = srvyr::survey_mean
agrupacion = disenio$agrupacion
conglomerado = disenio$conglomerado
estrato = disenio$estrato
peso = disenio$peso
variable = disenio$variable
col_prefix = "media_"

# set j = 1 for the MWE

j <- 1

# here is a fraction of the package internals

filter_values <- d_groups %>% dplyr::slice(j)
filter_syms <- purrr::map2(names(filter_values), filter_values, ~rlang::expr(!!sym(.x) == !!.y))

des2 <- des %>%
  dplyr::filter(!!!filter_syms)

What doesn't work

This worked with older tibble:: versions

# also taken from the package

des2 <- des2 %>%
  dplyr::group_by(!!!syms(c(agrupacion))) %>%
  dplyr::summarise(
    !!sym(paste0(col_prefix, variable)) := stat_fun(!!sym(variable), vartype = "ci", df = survey::degf(des2))
  )

Error: No common type for `..1` <svyby<>> and `..2` <data.frame<>>.

My setup

I installed the full tidyverse from github in order to reproduce the errors reported in CRAN. Here is the sessionInfo():

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 18.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] purrr_0.3.3       dplyr_0.8.99.9002 rlang_0.4.5.9000  casen_0.1.3       testthat_2.3.2   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4         compiler_3.6.3     pillar_1.4.3       forcats_0.5.0.9000
 [5] tools_3.6.3        pkgload_1.0.2      lifecycle_0.2.0    tibble_3.0.0      
 [9] lattice_0.20-40    pkgconfig_2.0.3    Matrix_1.2-18      DBI_1.1.0         
[13] cli_2.0.2          rstudioapi_0.11    haven_2.2.0        srvyr_0.3.8       
[17] withr_2.1.2        generics_0.0.2     desc_1.2.0         vctrs_0.2.99.9010 
[21] mitools_2.4        hms_0.5.3          rprojroot_1.3-2    grid_3.6.3        
[25] tidyselect_1.0.0   glue_1.4.0         R6_2.4.1           fansi_0.4.1       
[29] survival_3.1-11    tidyr_1.0.2.9000   magrittr_1.5       backports_1.1.6   
[33] ellipsis_0.3.0     splines_3.6.3      labelled_2.2.2     assertthat_0.2.1  
[37] utf8_1.1.4         survey_4.0         crayon_1.3.4
0 Answers
Related