summarytools icon indicating copy to clipboard operation
summarytools copied to clipboard

report.nas does not work for freq() when using kable()

Open JasonGellis opened this issue 5 years ago • 5 comments

under freq() function report.nas = FALSE does not seem to work

JasonGellis avatar Feb 12 '19 16:02 JasonGellis

Could you pls provide more details (small example and summarytools version)? Thx

dcomtois avatar Feb 12 '19 22:02 dcomtois

Will re-open if and when more info is provided

dcomtois avatar Feb 20 '19 19:02 dcomtois

I seem to have the same problem when printing the table.

freq(A$B, report.nas = FALSE, headings = FALSE) work just fine.

I have the same issue though when storing the result as an object and than printing it with kableExtra (I'm using rmarkdown).

` ####create table object table_object <- freq(A$B, report.nas = FALSE, headings = FALSE)

####direct print works oke table_object

####printing with cable doesn't give the expected result but includes <NA> row and % Valid and % Valid Cum. columns table_object %>% kable() %>% kable_paper(full_width = F) `

jendrik20 avatar Apr 13 '22 12:04 jendrik20

@jendrik20 @dcomtois This happens because the freq output actually does not change as a matrix object. report.nas = FALSE is saved as an attribute which is later used by print.summarytools. The suitable way to use in R Markdown documents seems to be print(table_object, method = "render").

However, I am not sure if it is possible to get a kable output in order to be reformatted by kableExtra functions like kable_paper.

iago-pssjd avatar Oct 28 '22 07:10 iago-pssjd

Please try using the tb() function, which should allow you to manipulate the table adequately.

dcomtois avatar Nov 07 '22 02:11 dcomtois