Add a row of new columns labels in footer 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.

add_footer_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.

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

Illustrations

See also

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

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

Examples

ft_1 <- flextable(head(iris))
ft_1 <- add_footer_row(ft_1,
  values = "blah blah", colwidths = 5
)
ft_1 <- add_footer_row(ft_1,
  values = c("blah", "blah"),
  colwidths = c(3, 2)
)
ft_1
#> a flextable object.
#> col_keys: `Sepal.Length`, `Sepal.Width`, `Petal.Length`, `Petal.Width`, `Species` 
#> header has 1 row(s) 
#> body has 6 row(s) 
#> original dataset sample: 
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa