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.
a flextable object
should the row be inserted at the top or the bottom. Default to TRUE.
values to add, a character vector (as header rows contains only character values/columns) or a list.
the number of columns used for each label
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()
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
#> a flextable object.
#> col_keys: `Sepal.Length`, `Sepal.Width`, `Petal.Length`, `Petal.Width`, `Species`
#> header has 3 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