Learn R Programming

flextable (version 0.8.2)

add_header_row: Add header labels

Description

Add a row of new columns labels in header part. Labels can be spanned along multiple columns, as merged cells.

Labels are associated with a number of columns to merge that default to one if not specified. In this case, you have to make sure that the number of labels is equal to the number of columns displayed.

The function can add only one single row by call.

Usage

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

Arguments

x

a flextable object

top

should the row be inserted at the top or the bottom. Default to TRUE.

values

values to add, a character vector (as header rows contains only character values/columns) or a list.

colwidths

the number of columns used for each label

Illustrations

See Also

Other functions that add lines in the table: add_body_row(), add_body(), add_footer_lines(), add_footer_row(), add_footer(), add_header()

Other functions to add rows in header or footer: add_footer_lines(), add_footer_row(), add_footer(), add_header_lines(), add_header(), separate_header(), set_header_footer_df, set_header_labels()

Examples

Run this code
ft_1 <- flextable(head(iris))
ft_1 <- add_header_row(ft_1,
  values = "blah blah", colwidths = 5
)
ft_1 <- add_header_row(ft_1,
  values = c("blah", "blah"),
  colwidths = c(3, 2)
)
ft_1

Run the code above in your browser using DataLab