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

Warning message when using insert_rrow #199

Closed
anajens opened this issue May 10, 2021 · 3 comments
Closed

Warning message when using insert_rrow #199

anajens opened this issue May 10, 2021 · 3 comments

Comments

@anajens
Copy link
Contributor

anajens commented May 10, 2021

There is a new warning message when using insert_rrow :

library(rtables)
tbl <- basic_table() %>%
  split_cols_by("ARM") %>%
  analyze("AGE") %>%
  build_table(ex_adsl)

insert_rrow(tbl, rrow("Total xx", ""), at = 1)
Warning message:
In matrix(cstrs, byrow = TRUE, nrow = nrow(tt), ncol = ncol(tt)) :
  data length [4] is not a sub-multiple or multiple of the number of columns [3]

Session info:

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblasp-r0.2.19.so

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

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

other attached packages:
[1] rtables_0.3.7.0004 magrittr_2.0.1    

loaded via a namespace (and not attached):
[1] compiler_3.6.3  htmltools_0.4.0 tools_3.6.3     Rcpp_1.0.4.6    digest_0.6.25   packrat_0.5.0   rlang_0.4.9 
@gmbecker
Copy link
Collaborator

@anajens This actually seems like it should be an error. The row you're inserting doesn't have the correct number of columns. ie it has one column's worth of data (its "" but thats still a value, so its not a label row), but the table has 3. It has no meaningful way of conforming those two.

That said, if you are trying to forcibly insert a label row, if you don't specify row data at all (or use NULL, rather than "") and just give a row label, this works as is:

> insert_rrow(tbl, rrow("Total xx"), at = 1)
           A: Drug X   B: Placebo   C: Combination
--------------------------------------------------
Total xx                                          
Mean         33.77       35.43          35.43     

Does that cover the use-case where this warning arose for you in the wild?

@anajens
Copy link
Contributor Author

anajens commented May 11, 2021

Thanks @gmbecker, that solves it! I guess for some reason our unit tests had this set up and previously it was raising a warning but I will update them now.

@gmbecker
Copy link
Collaborator

@anajens fyi as suggested in the commit message above this would now be a (hopefully more informative) error in cases where you are inserting something that has no formal col_info but has the wrong non-zero number of columns. Same for rbinding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants