atorus-research / Tplyr

https://atorus-research.github.io/Tplyr/
Other
95 stars 16 forks source link

Tplyr not computing header n's when adding layers programatically #185

Closed asbates closed 1 month ago

asbates commented 1 month ago

Prerequisites

For more information, see the CONTRIBUTING guide.

Description

When adding layers programmatically, Tplyr is not computing (or not finding) the header_n values.

Steps to Reproduce (Bug Report Only)

library(Tplyr)

t <- tplyr_table(mtcars, gear)

layers <- list(
  group_count(t, cyl),
  group_desc(t, hp)
)

t <- add_layers(t, !!!layers)

header_n(t)
#> Error in `env_get()`:
#> ! Can't find `header_n` in environment.

Created on 2024-08-27 with reprex v2.1.1

Expected behavior: I get a data frame with the header_n values.

Actual behavior: I get an error.

Versions

You can get this information from executing sessionInfo().

R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

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

time zone: Etc/UTC
tzcode source: system (glibc)

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

loaded via a namespace (and not attached):
 [1] digest_0.6.36     R6_2.5.1          utf8_1.2.4        fastmap_1.2.0     xfun_0.45         magrittr_2.0.3   
 [7] glue_1.7.0        tibble_3.2.1      knitr_1.47        pkgconfig_2.0.3   htmltools_0.5.8.1 rmarkdown_2.27   
[13] lifecycle_1.0.4   ps_1.7.6          cli_3.6.3         processx_3.8.4    fansi_1.0.6       callr_3.7.6      
[19] vctrs_0.6.5       reprex_2.1.1      withr_3.0.0       pkgload_1.3.4     compiler_4.3.0    rstudioapi_0.15.0
[25] tools_4.3.0       pillar_1.9.0      evaluate_0.24.0   yaml_2.3.8        rlang_1.1.4       fs_1.6.4 
mstackhouse commented 1 month ago

@asbates this isn't a bug - it's just that the table isn't built and the error here isn't intuitive:

library(Tplyr)

t <- tplyr_table(mtcars, gear)

layers <- list(
  group_count(t, cyl),
  group_desc(t, hp)
)

t <- add_layers(t, !!!layers)

build(t)

header_n(t)

The header N table just isn't computed until build time.