% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/augment_rows.R
\name{add_footer}
\alias{add_footer}
\title{Add footer rows with one value per column}
\usage{
add_footer(x, top = TRUE, ..., values = NULL)
}
\arguments{
\item{x}{a 'flextable' object, see \link{flextable-package} to learn how to create
'flextable' object.}

\item{top}{should the rows be inserted at the top or the bottom.}

\item{...}{named arguments (names are data colnames) of values
to add. It is important to insert data of the same type as the
original data, otherwise it will be transformed (probably
into strings if you add a \code{character} where a \code{double} is expected).
This makes possible to still format cell contents with the \verb{colformat_*}
functions, for example \code{\link[=colformat_num]{colformat_num()}}.}

\item{values}{a list of name-value pairs of labels or values,
names should be existing col_key values. This argument can be used
instead of \code{...} for programming purpose (If \code{values} is
supplied argument \code{...} is ignored).}
}
\description{
Add new rows to the footer where each value maps to a named column.
Unlike \code{\link[=add_footer_row]{add_footer_row()}} where labels can span multiple columns,
here each value fills exactly one column.

If some columns are not provided, they will be replaced by
\code{NA} and displayed as empty.
}
\examples{
new_row <- as.list(colMeans(iris[, -5]))
new_row$Species <- "Means"

formatter <- function(x) sprintf("\%.1f", x)

ft <- flextable(data = head(iris))
ft <- add_footer(ft, values = new_row)

# cosmetics
ft <- compose(
  x = ft, j = 1:4,
  value = as_paragraph(
    as_chunk(., formatter = formatter)
  ),
  part = "footer", use_dot = TRUE
)
ft <- align(ft, part = "footer", align = "right", j = 1:4)
ft
}
\seealso{
Other row and column operations:
\code{\link[=add_body]{add_body()}},
\code{\link[=add_body_row]{add_body_row()}},
\code{\link[=add_footer_lines]{add_footer_lines()}},
\code{\link[=add_footer_row]{add_footer_row()}},
\code{\link[=add_header]{add_header()}},
\code{\link[=add_header_lines]{add_header_lines()}},
\code{\link[=add_header_row]{add_header_row()}},
\code{\link[=delete_columns]{delete_columns()}},
\code{\link[=delete_part]{delete_part()}},
\code{\link[=delete_rows]{delete_rows()}},
\code{\link[=paginate]{paginate()}},
\code{\link[=separate_header]{separate_header()}},
\code{\link{set_header_footer_df}},
\code{\link[=set_header_labels]{set_header_labels()}},
\code{\link[=split_columns]{split_columns()}},
\code{\link[=split_rows]{split_rows()}},
\code{\link[=split_to_pages]{split_to_pages()}}
}
\concept{table_structure}
