Learn R Programming

flextable (version 0.4.0)

add_header: Add a row of labels in headers

Description

Add a single row of labels in the flextable's header part. It can be inserted at the top or the bottom of header part.

Usage

add_header(x, top = TRUE, ...)

Arguments

x

a flextable object

top

should the row be inserted at the top or the bottom.

...

a named list (names are data colnames) of strings specifying corresponding labels to add.

Details

An horizontal and a vertical merge are performed automatically. Use merge_none to drop theses merging instructions.

Examples

Run this code
# NOT RUN {
ft <- flextable( head( iris ),
  col_keys = c("Species", "Sepal.Length", "Petal.Length", "Sepal.Width", "Petal.Width") )
ft <- add_header(x = ft, Sepal.Length = "length",
  Sepal.Width = "width", Petal.Length = "length",
  Petal.Width = "width", Species = "Species", top = FALSE )
ft <- add_header(ft, Sepal.Length = "Inches",
  Sepal.Width = "Inches", Petal.Length = "Inches",
  Petal.Width = "Inches", Species = "Species", top = TRUE )
ft <- merge_h(ft, part = "header")
ft
# }

Run the code above in your browser using DataLab