Skip to content

tabyl() handles dates correctly when it's one of two variables but not when it's one of three #592

@chris-beech

Description

@chris-beech

I love tabyl and use it every day (thank you!) but one thing always catches me out:

library(tidyverse)
library(janitor)

df <- tibble(
  Date = as_date(c("2025-01-01", "2025-01-01", "2025-01-02")),
  a = c(1, 1, 2),
  b = c(1, 0, 1)
)

df |> tabyl(Date, a) # this is fine
df |> tabyl(Date, b) # this is fine

df |> tabyl(Date, a, b) # this gives the error below

Warning messages: 1: In as.POSIXlt(.Internal(Date2POSIXlt(x, tz)), tz = tz) : NAs introduced by coercion 2: In as.POSIXlt(.Internal(Date2POSIXlt(x, tz)), tz = tz) : NAs introduced by coercion

R version 4.5.0 (2025-04-11)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

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

other attached packages:
 [1] dbplyr_2.5.0    odbc_1.6.0      DBI_1.2.3       janitor_2.2.1   lubridate_1.9.4 forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4     purrr_1.0.4     readr_2.1.5    
[11] tidyr_1.3.1     tibble_3.2.1    ggplot2_3.5.2   tidyverse_2.0.0

loaded via a namespace (and not attached):
 [1] bit_4.6.0          gtable_0.3.6       compiler_4.5.0     tidyselect_1.2.1   Rcpp_1.0.14        blob_1.2.4         snakecase_0.11.1   scales_1.4.0      
 [9] R6_2.6.1           generics_0.1.4     pillar_1.10.2      RColorBrewer_1.1-3 tzdb_0.5.0         rlang_1.1.6        utf8_1.2.5         stringi_1.8.7     
[17] bit64_4.6.0-1      timechange_0.3.0   cli_3.6.5          withr_3.0.2        magrittr_2.0.3     grid_4.5.0         rstudioapi_0.17.1  hms_1.1.3         
[25] lifecycle_1.0.4    vctrs_0.6.5        glue_1.8.0         farver_2.1.2       tools_4.5.0        pkgconfig_2.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions