flextable (version 0.5.1)

add_header_footer: Add a row of labels in header or footer part

Description

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

Usage

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

add_header_row(x, top = TRUE, values = character(0), colwidths = integer(0))

add_footer_row(x, top = TRUE, values = character(0), colwidths = integer(0))

add_footer_lines(x, values = character(0), top = FALSE)

add_header_lines(x, values = character(0), top = TRUE)

add_footer(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.

values

values to add as a character vector

colwidths

the number of columns to merge in the row for each label

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 <- add_footer(ft, Species = "This is a footnote" )
ft <- merge_at(ft, j = 1:5, part = "footer")
ft
ft <- flextable( head( iris ) )
ft <- add_header_row(ft, values = "blah blah", colwidths = 5)
ft <- add_header_row(ft, values = c("blah", "blah"), colwidths = c(3,2))
ft
ft <- flextable( head( iris ) )
ft <- add_footer_row(ft, values = "blah blah", colwidths = 5)
ft <- add_footer_row(ft, values = c("blah", "blah"), colwidths = c(3,2))
ft
ft <- flextable( head( iris ) )
ft <- add_footer_lines(ft, values = "blah blah")
ft <- add_footer_lines(ft, values = c("blah 1", "blah 2"))
autofit(ft)
ft <- flextable( head( iris ) )
ft <- add_header_lines(ft, values = "blah blah")
ft <- add_header_lines(ft, values = c("blah 1", "blah 2"))
autofit(ft)
# }

Run the code above in your browser using DataCamp Workspace