Hi, a flextable object is a list.
I have read this:
https://stackoverflow.com/questions/4227223/convert-a-list-to-a-data-frame
It seems that it is a special list as I tried and got an error saying that can't convert class flextable into class dataframe.
But maybe there is a way ?
My code:
library(flextable)
library(tidyverse)
X <- c("Q1", "Q2", "Q3", "Q4")
Y <- c(342, 435, 443, 224)
XY <- data.frame(X, Y)
flex_XY <- flextable(XY)
ft_1 <- add_header_row(flex_XY,
values = c("", ""))
ft_1x <- ft_1 %>% flextable::add_header_row(top = TRUE, values = c("Something goes here", "")) |> merge_at(i = 1, j = 1:2,
part = "header") |> flextable::align(align = "center", j = c(1:2), part = "header")
ft_1x |> as.data.frame()