| add_body_row | R Documentation |
Add a single row to the body where labels can span
multiple columns (merged cells) via the colwidths argument.
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.
Labels can also be formatted with as_paragraph().
add_body_row(x, top = TRUE, values = list(), colwidths = integer(0))
x |
a 'flextable' object, see flextable-package to learn how to create 'flextable' object. |
top |
should the row be inserted at the top or the bottom. |
values |
values to add. It can be a If it is a list, it can be a named list with the names of the columns of the
original data.frame or the |
colwidths |
the number of columns to merge in the row for each label |
flextable(), set_caption()
Other row and column operations:
add_body(),
add_footer(),
add_footer_lines(),
add_footer_row(),
add_header(),
add_header_lines(),
add_header_row(),
delete_columns(),
delete_part(),
delete_rows(),
paginate(),
separate_header(),
set_header_footer_df,
set_header_labels(),
split_columns(),
split_rows(),
split_to_pages()
library(flextable)
ft01 <- fp_text_default(color = "red")
ft02 <- fp_text_default(color = "orange")
pars <- as_paragraph(
as_chunk(c("(1)", "(2)"), props = ft02), " ",
as_chunk(
c(
"My tailor is rich",
"My baker is rich"
),
props = ft01
)
)
ft_1 <- flextable(head(mtcars))
ft_1 <- add_body_row(ft_1,
values = pars,
colwidths = c(5, 6), top = FALSE
)
ft_1 <- add_body_row(ft_1,
values = pars,
colwidths = c(3, 8), top = TRUE
)
ft_1 <- theme_box(ft_1)
ft_1
ft_2 <- flextable(head(airquality))
ft_2 <- add_body_row(ft_2,
values = c("blah", "bleeeh"),
colwidths = c(4, 2), top = TRUE
)
ft_2 <- theme_box(ft_2)
ft_2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.