# NOT RUN {
ft <- flextable( head( iris ),
col_keys = c("Species", "Sepal.Length", "Petal.Length",
"Sepal.Width", "Petal.Width") )
# start with no header
ft <- delete_part(ft, part = "header")
# add a line of row
ft <- add_header(x = ft, Sepal.Length = "length",
Sepal.Width = "width", Petal.Length = "length",
Petal.Width = "width", Species = "Species", top = FALSE )
# add another line of row at the top position
ft <- add_header(ft, Sepal.Length = "Inches",
Sepal.Width = "Inches", Petal.Length = "Inches",
Petal.Width = "Inches", top = TRUE )
# merge horizontally when there are identical values
ft <- merge_h(ft, part = "header")
# add a footnote in the footer part
ft <- add_footer(ft, Species = "This is a note in footer" )
ft <- merge_at(ft, j = 1:5, part = "footer")
# theme the table
ft <- theme_box(ft)
ft
# }
Run the code above in your browser using DataLab