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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/summarizor.R
\name{fmt_2stats}
\alias{fmt_2stats}
\alias{fmt_summarizor}
\title{format content for data generated with summarizor()}
\usage{
fmt_2stats(
stat,
num1,
num2,
cts,
pcts,
num1_mask = "\%.01f",
num2_mask = "(\%.01f)",
cts_mask = "\%.0f",
pcts_mask = "(\%.02f\%\%)"
)
fmt_summarizor(
stat,
num1,
num2,
cts,
pcts,
num1_mask = "\%.01f",
num2_mask = "(\%.01f)",
cts_mask = "\%.0f",
pcts_mask = "(\%.02f\%\%)"
)
}
\arguments{
\item{stat}{a character column containing the name of statictics}
\item{num1}{a numeric statistic to display such as a mean or a median}
\item{num2}{a numeric statistic to display such as a standard
deviation or a median absolute deviation.}
\item{cts}{a count to display}
\item{pcts}{a percentage to display}
\item{num1_mask}{format associated with \code{num1}, a format string
used by \code{\link[=sprintf]{sprintf()}}.}
\item{num2_mask}{format associated with \code{num2}, a format string
used by \code{\link[=sprintf]{sprintf()}}.}
\item{cts_mask}{format associated with \code{cts}, a format string
used by \code{\link[=sprintf]{sprintf()}}.}
\item{pcts_mask}{format associated with \code{pcts}, a format string
used by \code{\link[=sprintf]{sprintf()}}.}
}
\description{
This function was written to allow easy demonstrations
of flextable's ability to produce table summaries (with \code{\link[=summarizor]{summarizor()}}).
It assumes that we have either a quantitative variable, in which
case we will display the mean and the standard deviation, or a
qualitative variable, in which case we will display the count and the
percentage corresponding to each modality.
}
\examples{
library(flextable)
z <- summarizor(iris, by = "Species")
tab_1 <- tabulator(
x = z,
rows = c("variable", "stat"),
columns = "Species",
blah = as_paragraph(
as_chunk(
fmt_summarizor(
stat = stat,
num1 = value1, num2 = value2,
cts = cts, pcts = percent
)
)
)
)
ft_1 <- as_flextable(x = tab_1, separate_with = "variable")
ft_1 <- labelizor(
x = ft_1, j = "stat",
labels = c(mean_sd = "Moyenne (ecart-type)",
median_iqr = "Mediane (IQR)",
range = "Etendue",
missing = "Valeurs manquantes"
)
)
ft_1 <- autofit(ft_1)
ft_1
}
\seealso{
\code{\link[=summarizor]{summarizor()}}, \code{\link[=tabulator]{tabulator()}}, \code{\link[=mk_par]{mk_par()}}
Other text formatter functions:
\code{\link{fmt_avg_dev}()},
\code{\link{fmt_header_n}()},
\code{\link{fmt_n_percent}()}
}
\concept{text formatter functions}
|