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 72 73 74 75 76 77 78 79 80 81 82 83 84
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/augment_rows.R
\name{separate_header}
\alias{separate_header}
\title{Separate collapsed colnames into multiple rows}
\usage{
separate_header(
x,
opts = c("span-top", "center-hspan", "bottom-vspan", "default-theme"),
split = "[_\\\\.]",
fixed = FALSE
)
}
\arguments{
\item{x}{a flextable object}
\item{opts}{optional treatments to apply
to the resulting header part as a character
vector with multiple supported values.
The supported values are:
\itemize{
\item "span-top": span empty cells with the
first non empty cell, this operation is made
column by column.
\item "center-hspan": center the cells that are
horizontally spanned.
\item "bottom-vspan": bottom align the cells treated
when "span-top" is applied.
\item "default-theme": apply to the new header part
the theme set in \code{set_flextable_defaults(theme_fun = ...)}.
}}
\item{split}{a regular expression (unless \code{fixed = TRUE})
to use for splitting.}
\item{fixed}{logical. If TRUE match \code{split} exactly,
otherwise use regular expressions.}
}
\description{
If your variable names contain
multiple delimited labels, they will be separated
and placed in their own rows.
\if{html}{\out{
<img src="https://www.ardata.fr/img/flextable-imgs/flextable-016.png" alt="add_header illustration" style="width:100\%;">
}}
}
\examples{
library(flextable)
x <- data.frame(
Species = as.factor(c("setosa", "versicolor", "virginica")),
Sepal.Length_mean = c(5.006, 5.936, 6.588),
Sepal.Length_sd = c(0.35249, 0.51617, 0.63588),
Sepal.Width_mean = c(3.428, 2.77, 2.974),
Sepal.Width_sd = c(0.37906, 0.3138, 0.3225),
Petal.Length_mean = c(1.462, 4.26, 5.552),
Petal.Length_sd = c(0.17366, 0.46991, 0.55189),
Petal.Width_mean = c(0.246, 1.326, 2.026),
Petal.Width_sd = c(0.10539, 0.19775, 0.27465)
)
ft_1 <- flextable(x)
ft_1 <- colformat_double(ft_1, digits = 2)
ft_1 <- theme_box(ft_1)
ft_1 <- separate_header(
x = ft_1,
opts = c("span-top", "bottom-vspan")
)
ft_1
}
\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_footer}()},
\code{\link{add_header_row}()},
\code{\link{add_header}()},
\code{\link{set_header_footer_df}},
\code{\link{set_header_labels}()}
}
\concept{functions to add rows in a flextable}
|