Pivot a crosstable so the label
column is swapped with the by
row.
This requires the variable
column to be the same for every data column, like when all columns are numeric of when all columns are factors with the same levels
Usage
transpose_crosstable(x)
# S3 method for crosstable
t(x)
Examples
ct = crosstable(mtcars2, c(mpg, drat, wt, qsec), by=am)
t_ct = t(ct)
as_flextable(t_ct)
am
variable
label
Miles/(US) gallon
Rear axle ratio
Weight (1000 lbs)
1/4 mile time
auto
Min / Max
10.4 / 24.4
2.8 / 3.9
2.5 / 5.4
15.4 / 22.9
Med [IQR]
17.3 [14.9;19.2]
3.1 [3.1;3.7]
3.5 [3.4;3.8]
17.8 [17.2;19.2]
Mean (std)
17.1 (3.8)
3.3 (0.4)
3.8 (0.8)
18.2 (1.8)
N (NA)
19 (0)
19 (0)
19 (0)
19 (0)
manual
Min / Max
15.0 / 33.9
3.5 / 4.9
1.5 / 3.6
14.5 / 19.9
Med [IQR]
22.8 [21.0;30.4]
4.1 [3.9;4.2]
2.3 [1.9;2.8]
17.0 [16.5;18.6]
Mean (std)
24.4 (6.2)
4.0 (0.4)
2.4 (0.6)
17.4 (1.8)
N (NA)
13 (0)
13 (0)
13 (0)
13 (0)