Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbind() fails when appending tsibbles with yearmonth indices #256

Closed
mbg-unsw opened this issue Apr 28, 2021 · 4 comments
Closed

rbind() fails when appending tsibbles with yearmonth indices #256

mbg-unsw opened this issue Apr 28, 2021 · 4 comments

Comments

@mbg-unsw
Copy link

mbg-unsw commented Apr 28, 2021


When I use rbind() to append two tsibbles with yearmonth indices, I get this error:

Error: `levels.yearmonth()` not supported.

e.g.

l1 <- tsibble(t=yearmonth("2020 Jan"), n=1, cat="a", index=t, key=cat)
l2 <- tsibble(t=yearmonth("2020 Jan"), n=1, cat="b", index=t, key=cat)
rbind(l1, l2)

The operation works as expected if the index is a plain date.

> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux bullseye/sid

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
 [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] tsibble_0.9.4

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        lubridate_1.7.9.2 assertthat_0.2.1  crayon_1.4.0     
 [5] dplyr_1.0.4       R6_2.5.0          DBI_1.1.1         lifecycle_0.2.0  
 [9] magrittr_2.0.1    pillar_1.4.7      rlang_0.4.10      rstudioapi_0.13  
[13] vctrs_0.3.6       generics_0.1.0    ellipsis_0.3.1    glue_1.4.2       
[17] purrr_0.3.4       anytime_0.3.9     compiler_4.0.4    pkgconfig_2.0.3  
[21] tidyselect_1.1.0  tibble_3.0.6     
@pollytatouin
Copy link

Same problem on my end:

x1 <- tsibble::tourism
x2 <- tsibble::tourism

rbind(x1, x2)

Erreur : `levels.yearquarter()` not supported.
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=French_Canada.1252  LC_CTYPE=French_Canada.1252    LC_MONETARY=French_Canada.1252 LC_NUMERIC=C                  
[5] LC_TIME=French_Canada.1252    

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

other attached packages:
 [1] lubridate_1.7.10  concordance_2.0.0 ggplot2_3.3.5     feasts_0.2.2      vroom_1.5.4       dplyr_1.0.7       fable_0.3.1       fabletools_0.3.1 
 [9] tsibble_1.0.1     stringr_1.4.0    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7           urca_1.3-0           progressr_0.8.0      pillar_1.6.2         compiler_4.1.0       tools_4.1.0          digest_0.6.27       
 [8] bit_4.0.4            lattice_0.20-44      nlme_3.1-152         lifecycle_1.0.0      tibble_3.1.3         gtable_0.3.0         anytime_0.3.9       
[15] pkgconfig_2.0.3      rlang_0.4.11         cli_3.0.1            parallel_4.1.0       withr_2.4.2          generics_0.1.0       vctrs_0.3.8         
[22] nnet_7.3-16          bit64_4.0.5          grid_4.1.0           tidyselect_1.1.1     data.table_1.14.0    glue_1.4.2           R6_2.5.0            
[29] fansi_0.5.0          distributional_0.2.2 farver_2.1.0         purrr_0.3.4          tidyr_1.1.3          tzdb_0.1.2           magrittr_2.0.1      
[36] scales_1.1.1         ellipsis_0.3.2       colorspace_2.0-2     numDeriv_2016.8-1.1  renv_0.14.0          utf8_1.2.2           stringi_1.7.3       
[43] munsell_0.5.0        crayon_1.4.1

earowang added a commit that referenced this issue Sep 26, 2021
earowang added a commit that referenced this issue Sep 26, 2021
earowang added a commit that referenced this issue Sep 26, 2021
@earowang
Copy link
Member

earowang commented Sep 26, 2021 via email

earowang added a commit that referenced this issue Oct 22, 2021
earowang added a commit that referenced this issue Oct 22, 2021
@Fuco1
Copy link

Fuco1 commented Nov 24, 2021

What was the reason behind reversing this patch? Somehow this worked for me for at least half a year and started failing after I updated to the current version. Interestingly it errors out somewhere deep inside ggplot. I don't know how it worked before, is it even possible it could've work? Maybe I was casting to tibble somewhere along the process :O

Anyway, why not support binding for tsibbles?

@earowang
Copy link
Member

earowang commented Dec 3, 2021

It's not much an issue if all inputs are tsibbles, but I don't think if a tsibble returned by rbind() is always valid. Anyway, the output of rbind() is often unpredictable, if inputs are various data classes. For example, the output can be a matrix. I have kept watching how {tibble} addressed the rbind() issue. And they eventually leave the issue as is ( tidyverse/tibble#909 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants