dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
522 stars 78 forks source link

feature: select columns in freq #35

Closed ptoche closed 3 years ago

ptoche commented 6 years ago

New to the package. Very interesting contribution! I may have missed this: is there a way to select the columns that freq returns? I can remove NAs with report.nas = FALSE. I know I can drop the Totals row with totals = FALSE. Is there an option of the freq function to keep/drop the percentage column and/or the cumulative percentage column?

Something like report.cum = FALSE and report.pct = FALSE ...

dcomtois commented 6 years ago

Hi & thanks for the feedback.

I hesitate, as the functions already have a good number of parameters and I don't want to add too many. I will however leave the issue open so that other users can weigh in.

Meanwhile, here are a few alternatives:

pander::pander(table(tobacco$gender, useNA = 'no'), style = 'rmarkdown')

F M
489 489
knitr::kable(table(tobacco$gender, useNA = 'ifany'),
                   col.names = c("Gender", "N"))
Gender N
F 489
M 489
NA 22
dcomtois commented 5 years ago

I've added a parameter "cumul" to freq(). So now you can have

> freq(tobacco$gender, cumul = FALSE, report.nas = FALSE, totals = FALSE)
Frequencies  
tobacco$gender  
Type: Factor  

           Freq       %
-------- ------ -------
       F    489   50.00
       M    489   50.00

Just install from the "dev-current" branch to try it out:

devtools::install_github("dcomtois/summarytools", ref = "dev-current")

ptoche commented 5 years ago

excellent!