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

Consider vec_proxy() and vec_restore() methods for IDate #1781

Open
DavisVaughan opened this issue Feb 6, 2023 · 2 comments
Open

Consider vec_proxy() and vec_restore() methods for IDate #1781

DavisVaughan opened this issue Feb 6, 2023 · 2 comments
Labels
bug an unexpected problem or unintended behavior op:proxy-restore

Comments

@DavisVaughan
Copy link
Member

From tidyverse/dplyr#6687

library(vctrs)
library(data.table)

x <- as.IDate("2017-06-05")
class(x)
#> [1] "IDate" "Date"

typeof(x)
#> [1] "integer"

typeof(vec_slice(x, 1))
#> [1] "double"

# Because of
typeof(vec_proxy(x))
#> [1] "double"

# Proxy is inherited from Date, which normalizes to double
vctrs:::vec_proxy.Date
#> function (x, ...) 
#> {
#>     date_validate(x)
#> }
#> <bytecode: 0x7fedebbeb8f0>
#> <environment: namespace:vctrs>
@buggaby
Copy link

buggaby commented May 2, 2024

I'm seeing this occur with a filter call on a data.table. Is this the same issue?

Dates = as.IDate(c("2018-04-02", "2018-04-03", "2018-04-04"))
Letters = c("A", "B", "C")
dt = data.table(Date = Dates, Letter = Letters)

dt %>%
	pull(Date) %>%
	typeof()
#> [1] "integer"

dt %>%
	filter(Letter != "A") %>%
	pull(Date) %>%
	typeof()
#> [1] "double"

@muschellij2
Copy link

This relates to @tidyverse dplyr too, which I don't think is expected behavior.

x = structure(1509375600L, class = c("POSIXct", "POSIXt"), tzone = "UTC")
typeof(x)
#> [1] "integer"
dplyr::first(x)
#> [1] "2017-10-30 15:00:00 UTC"
typeof(vctrs::vec_slice(x, 1L))
#> [1] "double"
typeof(dplyr::first(x))
#> [1] "double"

Created on 2024-07-15 with reprex v2.1.0

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.0 (2024-04-24)
#>  os       macOS Sonoma 14.4.1
#>  system   x86_64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/New_York
#>  date     2024-07-15
#>  pandoc   3.2 @ /usr/local/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.2   2023-12-11 [1] CRAN (R 4.4.0)
#>  digest        0.6.35  2024-03-11 [1] CRAN (R 4.4.0)
#>  dplyr         1.1.4   2023-11-17 [1] CRAN (R 4.4.0)
#>  evaluate      0.23    2023-11-01 [1] CRAN (R 4.4.0)
#>  fansi         1.0.6   2023-12-08 [1] CRAN (R 4.4.0)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.0)
#>  fs            1.6.4   2024-04-25 [1] CRAN (R 4.4.0)
#>  generics      0.1.3   2022-07-05 [1] CRAN (R 4.4.0)
#>  glue          1.7.0   2024-01-09 [1] CRAN (R 4.4.0)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
#>  knitr         1.46    2024-04-06 [1] CRAN (R 4.4.0)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.0)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.0)
#>  pillar        1.9.0   2023-03-22 [1] CRAN (R 4.4.0)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.4.0)
#>  purrr         1.0.2   2023-08-10 [1] CRAN (R 4.4.0)
#>  R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.4.0)
#>  R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.4.0)
#>  R.oo          1.26.0  2024-01-24 [1] CRAN (R 4.4.0)
#>  R.utils       2.12.3  2023-11-18 [1] CRAN (R 4.4.0)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.0)
#>  reprex        2.1.0   2024-01-11 [1] CRAN (R 4.4.0)
#>  rlang         1.1.3   2024-01-10 [1] CRAN (R 4.4.0)
#>  rmarkdown     2.27    2024-05-17 [1] CRAN (R 4.4.0)
#>  rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.4.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.0)
#>  styler        1.10.3  2024-04-07 [1] CRAN (R 4.4.0)
#>  tibble        3.2.1   2023-03-20 [1] CRAN (R 4.4.0)
#>  tidyselect    1.2.1   2024-03-11 [1] CRAN (R 4.4.0)
#>  utf8          1.2.4   2023-10-22 [1] CRAN (R 4.4.0)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.0)
#>  withr         3.0.0   2024-01-16 [1] CRAN (R 4.4.0)
#>  xfun          0.44    2024-05-15 [1] CRAN (R 4.4.0)
#>  yaml          2.3.8   2023-12-11 [1] CRAN (R 4.4.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior op:proxy-restore
Projects
None yet
Development

No branches or pull requests

3 participants