dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
502 stars 77 forks source link

Error message when vars are piped into ctable #168

Open BobMuenchen opened 2 years ago

BobMuenchen commented 2 years ago

summarytools is great! I've taught it in my R Markdown workshop for several years. This time, I switched to piping the variables in. It mostly works, but also generates an error message. Given the popularity of the tidyverse, it would be helpful if ctable accepted piped variables without the error message.

> library("tidyverse")
> 
> tobacco %>%
+ select(gender, smoker) %>%
+ ctable(prop = "r",
+        chisq = TRUE,
+        method = "render")
Error : Can't find NULL
Cross-Tabulation, Row Proportions  
structure(2L, levels = c("F", "M", "Yes", "No"), class = "factor") * structure(1L, levels = c("F", "M", "Yes", "No"), class = "factor")  
Data Frame: tobacco  

-------------------------------------------------------------------- -------------------------------------------------------------------- ------------- ------------- ---------------
                                                                       structure(1L, levels = c("F", "M", "Yes", "No"), class = "factor")           Yes            No           Total
  structure(2L, levels = c("F", "M", "Yes", "No"), class = "factor")                                                                                                                 
                                                                   F                                                                        147 (30.1%)   342 (69.9%)    489 (100.0%)
                                                                   M                                                                        143 (29.2%)   346 (70.8%)    489 (100.0%)
                                                                <NA>                                                                          8 (36.4%)    14 (63.6%)     22 (100.0%)
                                                               Total                                                                        298 (29.8%)   702 (70.2%)   1000 (100.0%)
-------------------------------------------------------------------- -------------------------------------------------------------------- ------------- ------------- ---------------

----------------------------
 Chi.squared   df   p.value 
------------- ---- ---------
   0.0441      1    0.8336  
----------------------------
dcomtois commented 1 year ago

Thanks for reporting this... It will require some work... the parse_args internal function will need to be modified in order to recognize this type of call.

As always, since I have limited time to dedicate to the package, help is always welcome.