Hi,
I'm having trouble modifying header labels when using flextable
within a user defined function. As shown below, set_header_labels(mpg = "Miles/Gallon")
modifies the header label, but not when I attempt to wrap it into a function. Any advice for how to do so would be greatly appreciated.
library(dplyr)
library(flextable)
# make a flextable and modify header label
mtcars %>%
head() %>%
flextable() %>%
set_header_labels(mpg = "Miles/Gallon")
# create function
tab_fun <- function(df, tab_var, var_lab) {
df %>%
head() %>%
flextable() %>%
set_header_labels(tab_var = var_lab)
}
# header label not modified
mtcars %>% tab_fun(mpg, "Miles/Gallon")
Created on 2022-04-08 by the reprex package (v2.0.0)