rpivot-tableflextable

R flextable proc_freq remove counts


I want to show a crosstab of two variables in a flextable, but only show row/column/table percentages, not counts.

For example, if I run the collowing code

library(flextable)
proc_freq(mtcars,"cyl","gear",include.row_percent = FALSE,include.table_percent = FALSE )

I get the cross-tab with column percentages AND counts. How do I remove the counts?

I realize this can't be done with preexisting options, but I'm hoping it is easy to change the proc_freq function to remove the counts. Going over the code for the function, I can't see how I would do that.

Any thoughts?


Solution

  • Since flextable 0.9.7, proc_freq() has an argument include.table_count that can be set to FALSE:

    library(flextable)
    proc_freq(
      mtcars, "cyl", "gear",
      include.row_percent = FALSE,
      include.column_percent = FALSE,
      include.table_percent = TRUE,
      include.table_count = FALSE
    )
    

    enter image description here