tidyverts / tsibble

Tidy Temporal Data Frames and Tools
https://tsibble.tidyverts.org
GNU General Public License v3.0
531 stars 49 forks source link

append_row not working with weekly data #212

Closed andrewwillis closed 4 years ago

andrewwillis commented 4 years ago

I am getting an error when trying to use append_row() with weekly data. Things work when my data has an interval of 7D, but not 1W.

Thank you for your help and any pointers on how to fix this!

library(tidyverse)
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following object is masked from 'package:lubridate':
#> 
#>     interval

raw_data <- tribble(
  ~date,        ~x,
  "2020-06-01", 10,
  "2020-06-08", 20,
  "2020-06-15", 30) %>% 
  mutate(date = ymd(date))

t <- raw_data %>% 
  mutate(date = yearweek(date)) %>% 
  as_tsibble(index = date)

t %>% 
  append_row(2)
#> Error: Internal error in `vec_proxy_assign_opts()`: `proxy` of type `double` incompatible with `value` proxy of type `integer`.

Created on 2020-07-23 by the reprex package (v0.3.0)

Session info ``` r sessionInfo() #> R version 3.6.2 (2019-12-12) #> Platform: x86_64-apple-darwin15.6.0 (64-bit) #> Running under: macOS Catalina 10.15.5 #> #> Matrix products: default #> BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib #> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib #> #> locale: #> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 #> #> attached base packages: #> [1] stats graphics grDevices datasets utils methods base #> #> other attached packages: #> [1] tsibble_0.9.1 lubridate_1.7.9 forcats_0.5.0 stringr_1.4.0 #> [5] dplyr_1.0.0 purrr_0.3.4 readr_1.3.1 tidyr_1.1.0 #> [9] tibble_3.0.3 ggplot2_3.3.2 tidyverse_1.3.0 #> #> loaded via a namespace (and not attached): #> [1] tidyselect_1.1.0 xfun_0.15 haven_2.3.1 colorspace_1.4-1 #> [5] vctrs_0.3.2 generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 #> [9] blob_1.2.1 rlang_0.4.7 pillar_1.4.6 glue_1.4.1 #> [13] withr_2.2.0 DBI_1.1.0 dbplyr_1.4.4 modelr_0.1.8 #> [17] readxl_1.3.1 lifecycle_0.2.0 anytime_0.3.7 munsell_0.5.0 #> [21] gtable_0.3.0 cellranger_1.1.0 rvest_0.3.5 evaluate_0.14 #> [25] knitr_1.29 fansi_0.4.1 highr_0.8 broom_0.7.0 #> [29] Rcpp_1.0.5 renv_0.11.0-6 scales_1.1.1 backports_1.1.8 #> [33] jsonlite_1.7.0 fs_1.4.2 hms_0.5.3 digest_0.6.25 #> [37] stringi_1.4.6 grid_3.6.2 cli_2.0.2 tools_3.6.2 #> [41] magrittr_1.5 crayon_1.3.4 pkgconfig_2.0.3 ellipsis_0.3.1 #> [45] xml2_1.3.2 reprex_0.3.0 assertthat_0.2.1 rmarkdown_2.3 #> [49] httr_1.4.2 R6_2.4.1 compiler_3.6.2 ```
earowang commented 4 years ago

If you install the dev version from Github, it should work.

I'll push a new CRAN release this week.

Cheers, Earo

On 24 Jul 2020, at 5:13, Andrew Willis wrote:

I am getting an error when trying to use append_row() with weekly data. Things work when my data has an interval of 7D, but not 1W.

Thank you for your help and any pointers on how to fix this!

library(tidyverse)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#>     date, intersect, setdiff, union
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following object is masked from 'package:lubridate':
#>
#>     interval

raw_data <- tribble(
  ~date,        ~x,
  "2020-06-01", 10,
  "2020-06-08", 20,
  "2020-06-15", 30) %>%
  mutate(date = ymd(date))

t <- raw_data %>%
  mutate(date = yearweek(date)) %>%
  as_tsibble(index = date)

t %>%
  append_row(2)
#> Error: Internal error in `vec_proxy_assign_opts()`: `proxy` of type 
`double` incompatible with `value` proxy of type `integer`.

Created on 2020-07-23 by the reprex package (v0.3.0)

Session info ``` r sessionInfo() #> R version 3.6.2 (2019-12-12) #> Platform: x86_64-apple-darwin15.6.0 (64-bit) #> Running under: macOS Catalina 10.15.5 #> #> Matrix products: default #> BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib #> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib #> #> locale: #> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 #> #> attached base packages: #> [1] stats graphics grDevices datasets utils methods base #> #> other attached packages: #> [1] tsibble_0.9.1 lubridate_1.7.9 forcats_0.5.0 stringr_1.4.0 #> [5] dplyr_1.0.0 purrr_0.3.4 readr_1.3.1 tidyr_1.1.0 #> [9] tibble_3.0.3 ggplot2_3.3.2 tidyverse_1.3.0 #> #> loaded via a namespace (and not attached): #> [1] tidyselect_1.1.0 xfun_0.15 haven_2.3.1 colorspace_1.4-1 #> [5] vctrs_0.3.2 generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 #> [9] blob_1.2.1 rlang_0.4.7 pillar_1.4.6 glue_1.4.1 #> [13] withr_2.2.0 DBI_1.1.0 dbplyr_1.4.4 modelr_0.1.8 #> [17] readxl_1.3.1 lifecycle_0.2.0 anytime_0.3.7 munsell_0.5.0 #> [21] gtable_0.3.0 cellranger_1.1.0 rvest_0.3.5 evaluate_0.14 #> [25] knitr_1.29 fansi_0.4.1 highr_0.8 broom_0.7.0 #> [29] Rcpp_1.0.5 renv_0.11.0-6 scales_1.1.1 backports_1.1.8 #> [33] jsonlite_1.7.0 fs_1.4.2 hms_0.5.3 digest_0.6.25 #> [37] stringi_1.4.6 grid_3.6.2 cli_2.0.2 tools_3.6.2 #> [41] magrittr_1.5 crayon_1.3.4 pkgconfig_2.0.3 ellipsis_0.3.1 #> [45] xml2_1.3.2 reprex_0.3.0 assertthat_0.2.1 rmarkdown_2.3 #> [49] httr_1.4.2 R6_2.4.1 compiler_3.6.2 ```

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/tidyverts/tsibble/issues/212

earowang commented 4 years ago

It's a duplicate of #199