1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/augment_rows.R
\name{add_footer}
\alias{add_footer}
\title{Add column values as new lines in footer}
\usage{
add_footer(x, top = TRUE, ..., values = NULL)
}
\arguments{
\item{x}{a 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{
The function adds a list of values to be inserted as
new rows in the footer. The values are inserted in
existing columns of the input data of the flextable.
Rows can be inserted at the top or the bottom of
the footer.
If some columns are not provided, they will be replaced by
\code{NA} and displayed as empty.
\if{html}{\out{
<img src="https://www.ardata.fr/img/flextable-imgs/flextable-016.png" alt="add_footer illustration" style="width:100\%;">
}}
}
\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 functions to add rows in a flextable:
\code{\link{add_body_row}()},
\code{\link{add_body}()},
\code{\link{add_footer_lines}()},
\code{\link{add_footer_row}()},
\code{\link{add_header_row}()},
\code{\link{add_header}()},
\code{\link{separate_header}()},
\code{\link{set_header_footer_df}},
\code{\link{set_header_labels}()}
}
\concept{functions to add rows in a flextable}
|