1

Is there a way to remove the label column from the proc_freq() flextable after it has been created?

When a flextable is created from scratch, i.e. from a dataframe, one can specify with col_keys the columns to display. However, proc_freq() generates the table itself.

How do I remove the "label" column in the following table?

library(flextable)
proc_freq(mtcars, "cyl", "gear")

enter image description here

user23413
  • 308
  • 2
  • 7

1 Answers1

1

These are 2 ways to do it :

library(flextable)
library(magrittr)
proc_freq(mtcars, "cyl", "gear") %>% 
  set_header_labels(label = "")

proc_freq(mtcars, "cyl", "gear") %>% 
  compose(i = 2, j = 2, value = as_paragraph(""), part = "header")
David Gohel
  • 9,180
  • 2
  • 16
  • 34
  • Thanks David! This only removes the label text but I was referring to the entire label column, i.e. remove completely column 2. I want to save space. Should this be then a combination of emptying the cells and merging with column 1? – user23413 Sep 25 '20 at 06:08
  • you can't delete a column from a flextable. yep, you could empty/merge – David Gohel Sep 25 '20 at 06:51