Can't combine `..1` <spec_tbl_df<>> and `..2` <tbl_df<>>

With the development version of vctrs and a data frame with subclass "spec_tbl_df", tidyr::pivot_longer() throws

#> Error: Can't combine `..1` <spec_tbl_df<>> and `..2` <tbl_df<>>

The error goes away by either attaching readr or removing the class "spec_tbl_df".

Does this look like an issue worth reporting? Which package should it be submitted?

packageVersion("vctrs")
#> [1] '0.2.99.9011'
packageVersion("tidyr")
#> [1] '1.0.2'
packageVersion("readr")
#> [1] '1.3.1'

# install.packages(r2dii.data)
(data <- dplyr::select(r2dii.data::loanbook_demo, 1:2)[1, ])
#> # A tibble: 1 x 2
#>   id_loan id_direct_loantaker
#>   <chr>   <chr>              
#> 1 L1      C294

class(data)
#> [1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame"
# Fails
tidyr::pivot_longer(data, cols = 1:2)
#> Error: Can't combine `..1` <spec_tbl_df<>> and `..2` <tbl_df<>>.

class(data[])
#> [1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame"
# Fails
tidyr::pivot_longer(data[], cols = 1:2)
#> Error: Can't combine `..1` <spec_tbl_df<>> and `..2` <tbl_df<>>.

# Create a copy to solve show two solutions
data1 <- data



# It works if I strip the class "spec_tbl_df"
# Solution 1: Explicitely
class(data) <- c("tbl_df", "tbl", "data.frame")
tidyr::pivot_longer(data, cols = 1:2)
#> # A tibble: 2 x 2
#>   name                value
#>   <chr>               <chr>
#> 1 id_loan             L1   
#> 2 id_direct_loantaker C294

# Solution 1: Via readr
library(readr)
tidyr::pivot_longer(data1, cols = 1:2)
#> # A tibble: 2 x 2
#>   name                value
#>   <chr>               <chr>
#> 1 id_loan             L1   
#> 2 id_direct_loantaker C294

Created on 2020-04-08 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.3 (2020-02-29)
#>  os       Ubuntu 18.04.4 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/Chicago             
#>  date     2020-04-08                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version     date       lib
#>  assertthat    0.2.1       2019-03-21 [1]
#>  backports     1.1.6       2020-04-05 [1]
#>  callr         3.4.3       2020-03-28 [1]
#>  cli           2.0.2       2020-02-28 [1]
#>  crayon        1.3.4.9000  2020-04-08 [1]
#>  desc          1.2.0       2018-05-01 [1]
#>  devtools      2.2.2       2020-02-17 [1]
#>  digest        0.6.25      2020-02-23 [1]
#>  dplyr         0.8.5       2020-03-07 [1]
#>  ellipsis      0.3.0       2019-09-20 [1]
#>  evaluate      0.14        2019-05-28 [1]
#>  fansi         0.4.1       2020-01-08 [1]
#>  fs            1.4.1       2020-04-04 [1]
#>  glue          1.4.0       2020-04-03 [1]
#>  highr         0.8         2019-03-20 [1]
#>  hms           0.5.3       2020-01-08 [1]
#>  htmltools     0.4.0       2019-10-04 [1]
#>  knitr         1.28        2020-02-06 [1]
#>  lifecycle     0.2.0       2020-03-06 [1]
#>  magrittr      1.5         2014-11-22 [1]
#>  memoise       1.1.0       2017-04-21 [1]
#>  pillar        1.4.3       2019-12-20 [1]
#>  pkgbuild      1.0.6       2019-10-09 [1]
#>  pkgconfig     2.0.3       2019-09-22 [1]
#>  pkgload       1.0.2       2018-10-29 [1]
#>  prettyunits   1.1.1       2020-01-24 [1]
#>  processx      3.4.2       2020-02-09 [1]
#>  ps            1.3.2       2020-02-13 [1]
#>  purrr         0.3.3       2019-10-18 [1]
#>  r2dii.data    0.0.3.9000  2020-04-06 [1]
#>  R6            2.4.1       2019-11-12 [1]
#>  Rcpp          1.0.4       2020-03-17 [1]
#>  readr       * 1.3.1       2018-12-21 [1]
#>  remotes       2.1.1       2020-02-15 [1]
#>  rlang         0.4.5.9000  2020-03-22 [1]
#>  rmarkdown     2.1         2020-01-20 [1]
#>  rprojroot     1.3-2       2018-01-03 [1]
#>  sessioninfo   1.1.1       2018-11-05 [1]
#>  stringi       1.4.6       2020-02-17 [1]
#>  stringr       1.4.0       2019-02-10 [1]
#>  testthat      2.3.2       2020-03-02 [1]
#>  tibble        3.0.0       2020-03-30 [1]
#>  tidyr         1.0.2       2020-01-24 [1]
#>  tidyselect    1.0.0       2020-01-27 [1]
#>  usethis       1.5.1.9000  2020-03-22 [1]
#>  utf8          1.1.4       2018-05-24 [1]
#>  vctrs         0.2.99.9011 2020-04-08 [1]
#>  withr         2.1.2       2018-03-15 [1]
#>  xfun          0.12        2020-01-13 [1]
#>  yaml          2.2.1       2020-02-01 [1]
#>  source                                       
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  Github (r-lib/crayon@e949005)                
#>  CRAN (R 3.6.3)                               
#>  standard (@2.2.2)                            
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  standard (@0.14)                             
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  standard (@0.8)                              
#>  CRAN (R 3.6.3)                               
#>  standard (@0.4.0)                            
#>  standard (@1.28)                             
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  standard (@1.1.0)                            
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  standard (@1.0.2)                            
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  standard (@0.3.3)                            
#>  Github (2degreesinvesting/r2dii.data@321e703)
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  standard (@1.3.1)                            
#>  standard (@2.1.1)                            
#>  Github (r-lib/rlang@a90b04b)                 
#>  standard (@2.1)                              
#>  CRAN (R 3.6.3)                               
#>  standard (@1.1.1)                            
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  standard (@2.3.2)                            
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  CRAN (R 3.6.3)                               
#>  Github (r-lib/usethis@6f62e04)               
#>  CRAN (R 3.6.3)                               
#>  Github (r-lib/vctrs@2d7ce56)                 
#>  CRAN (R 3.6.3)                               
#>  standard (@0.12)                             
#>  standard (@2.2.1)                            
#> 
#> [1] /home/mauro/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library

Was just about to respond here when the GH issue came through:

The issue is being tracked in vctrs here:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.