Flextable R: How to keep columns width after adding a header

Viewed 525

I have a tibble with two columns:

library('flextable')
library("tidyverse")

df <- tibble('Long' = "Long Long Long Long Long Text", 
             'Short' = 'Short Text')

Transform to a flextable:

ft <- flextable(data = df,
                theme_fun = theme_zebra)

So, I have a table with two equal columns:

enter image description here

Now I make the left column wider than the left one:

ft <- ft %>%
    width(j = 1,
          width = 4) %>%
    width(j = 2,
          width = 1)

enter image description here

And next I add a header:

ft <- ft %>%
   add_header_row(values = "Header", colwidths = 2)

enter image description here

As you can see, I now have the flextable with the header and columns of the SAME WIDTH. And no formatting helps anymore. How can I change the width of the columns?

0 Answers
Related