The function replace text values in a flextable with labels. The labels are defined with character named vector.
The function is not written to be fast but to be handy. It does
not replace the values in the underlying dataset but replace the defined
content in the flextable (as defined with compose()
).
Arguments
- x
a flextable object
- j
columns selection
- labels
a named vector whose names will be used to identify values to replace and values will be used as labels.
- part
partname of the table (one of 'all', 'body', 'header', 'footer')
Examples
z <- summarizor(
x = CO2[-c(1, 4)],
by = "Treatment",
overall_label = "Overall")
ft_1 <- as_flextable(z, separate_with = "variable")
ft_1 <- labelizor(
x = ft_1, j = c("stat"),
labels = c(Missing = "Kouign amann")
)
ft_1 <- labelizor(
x = ft_1, j = c("variable"),
labels = toupper
)
ft_1
nonchilled
(N=40)
chilled
(N=42)
Overall
(N=82)
PLANT
Qn1
5 (12.50%)
0 (0.00%)
5 (6.10%)
Qn2
7 (17.50%)
0 (0.00%)
7 (8.54%)
Qn3
7 (17.50%)
0 (0.00%)
7 (8.54%)
Qc1
0 (0.00%)
7 (16.67%)
7 (8.54%)
Qc3
0 (0.00%)
7 (16.67%)
7 (8.54%)
Qc2
0 (0.00%)
7 (16.67%)
7 (8.54%)
Mn3
7 (17.50%)
0 (0.00%)
7 (8.54%)
Mn2
7 (17.50%)
0 (0.00%)
7 (8.54%)
Mn1
7 (17.50%)
0 (0.00%)
7 (8.54%)
Mc2
0 (0.00%)
7 (16.67%)
7 (8.54%)
Mc3
0 (0.00%)
7 (16.67%)
7 (8.54%)
Mc1
0 (0.00%)
7 (16.67%)
7 (8.54%)
Kouign amann
0 (0.00%)
0 (0.00%)
0 (0.00%)
TYPE
Quebec
19 (47.50%)
21 (50.00%)
40 (48.78%)
Mississippi
21 (52.50%)
21 (50.00%)
42 (51.22%)
Kouign amann
0 (0.00%)
0 (0.00%)
0 (0.00%)
CONC
Mean (SD)
445.6 (299.9)
435.0 (297.7)
440.2 (297.0)
Median (IQR)
350.0 (500.0)
350.0 (500.0)
350.0 (500.0)
Range
95.0 - 1000.0
95.0 - 1000.0
95.0 - 1000.0
Kouign amann
0 (0.00%)
0 (0.00%)
0 (0.00%)
UPTAKE
Mean (SD)
30.8 (9.6)
23.8 (10.9)
27.2 (10.8)
Median (IQR)
31.3 (12.3)
19.7 (20.4)
28.3 (18.8)
Range
10.6 - 45.5
7.7 - 42.4
7.7 - 45.5
Kouign amann
0 (0.00%)
0 (0.00%)
0 (0.00%)