ropensci / daiquiri

Data quality reporting for temporal datasets.
https://ropensci.github.io/daiquiri/
GNU General Public License v3.0
35 stars 2 forks source link

Aggregation for integer columns not working #9

Closed fkohrt closed 2 years ago

fkohrt commented 2 years ago

I have to say that I find {daiquiri} a very cool package and am happy for the neat summaries it provides! While playing with it, I noticed the following:

It appears that aggregation doesn't work if columns are of type integer. The following example only works after uncommenting mutate(across(-date, as.numeric)):

library(dplyr)
library(daiquiri)
airquality |>
  mutate(across(c(Month, Day), \(x) formatC(x, width = 2, format = "d", flag = "0"))) |>
  mutate(date = paste0("1973-", Month, "-", Day)) |>
  select(-Month, -Day) |>
  #mutate(across(-date, as.numeric)) |>
  daiquiri_report(
    field_types = field_types(
      date = ft_timepoint(includes_time = FALSE),
      Ozone = ft_numeric(),
      Solar.R = ft_numeric(),
      Wind = ft_numeric(),
      Temp = ft_numeric()
    ),
    aggregation_timeunit = "week",
    save_filename = "daiquiri"
  )

Otherwise it results in the following error:

Error: Column 1 of result for group 2 is type 'integer' but expecting type 'double'. Column types must be consistent for each group.


sessionInfo() ``` R version 4.2.1 (2022-06-23) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so locale: [1] LC_CTYPE=en_US.UTF-8 [2] LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 [4] LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 [8] LC_NAME=C [9] LC_ADDRESS=C [10] LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 [12] LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets [6] methods base other attached packages: [1] daiquiri_1.0.2.9000 dplyr_1.0.10 loaded via a namespace (and not attached): [1] tidyselect_1.2.0 xfun_0.35 [3] purrr_0.3.5 generics_0.1.3 [5] colorspace_2.0-3 vctrs_0.5.1 [7] htmltools_0.5.3 yaml_2.3.6 [9] utf8_1.2.2 rlang_1.0.6 [11] pillar_1.8.1 DBI_1.1.3 [13] glue_1.6.2 withr_2.5.0 [15] bit64_4.0.5 lifecycle_1.0.3 [17] munsell_0.5.0 gtable_0.3.1 [19] evaluate_0.18 knitr_1.41 [21] tzdb_0.3.0 fastmap_1.1.0 [23] fansi_1.0.3 readr_2.1.3 [25] scales_1.2.1 vroom_1.6.0 [27] bit_4.0.5 hms_1.1.2 [29] ggplot2_3.4.0 digest_0.6.30 [31] grid_4.2.1 cli_3.4.1 [33] tools_4.2.1 magrittr_2.0.3 [35] tibble_3.1.8 crayon_1.5.2 [37] pkgconfig_2.0.3 ellipsis_0.3.2 [39] data.table_1.14.6 assertthat_0.2.1 [41] rmarkdown_2.18 rstudioapi_0.14 [43] R6_2.5.1 compiler_4.2.1 ```