Learn R Programming

flextable (version 0.7.2)

add_body_row: Add body labels

Description

Add a row of new columns labels in body 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_body_row(x, top = TRUE, values = list(), colwidths = integer(0))

Arguments

x

a flextable object

top

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

values

values to add. It can be a list or a character() vector. If it is a list, it must be a named list using the names of the columns of the original data.frame or the colkeys; this is the recommended method because it allows to keep the original data types and therefore allows to perform conditional formatting. If a character, columns of the original data.frame stored in the flextable object are changed to character(); this is often not an issue with footer and header but can be inconvenient if adding rows into body as it will change data types to character and prevent efficient conditional formatting.

colwidths

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

See Also

flextable(), add_header_row()

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

Examples

Run this code
ft <- flextable(head(iris))
ft <- add_body_row(ft, values = list(1000), colwidths = 5)
ft

Run the code above in your browser using DataLab