Skip to contents

[Experimental]
Combine multiple crosstables into one. This makes it possible to have multi-column crosstables with intra-group margins. A better solution will be found later.

Usage

ct_bind_cols(...)

Arguments

...

crosstable objects

Value

a wider crosstable

Examples

ct1 = mtcars2 %>%
crosstable(c(disp, cyl), by=c(am, vs),
           margin=c("row", "col"))

ct2 = mtcars2 %>%
  dplyr::mutate(vs="Total") %>%
  crosstable(c(disp, cyl), by=c(am, vs),
             margin=c("row", "col"))

ct_bind_cols(ct1, ct2) %>%
  af(header_show_n=TRUE)

Engine

straight (N=14)

vshaped (N=18)

Total (N=32)

Transmission

auto (N=7)

manual (N=7)

auto (N=12)

manual (N=6)

auto (N=19)

manual (N=13)

Displacement (cu.in.)

Min / Max

120.1 / 258.0

71.1 / 121.0

275.8 / 472.0

120.3 / 351.0

120.1 / 472.0

71.1 / 351.0

Med [IQR]

167.6 [143.8;196.3]

79.0 [77.2;101.5]

355.0 [296.9;410.0]

160.0 [148.8;265.8]

275.8 [196.3;360.0]

120.3 [79.0;160.0]

Mean (std)

175.1 (49.1)

89.8 (18.8)

357.6 (71.8)

206.2 (95.2)

290.4 (110.2)

143.5 (87.2)

N (NA)

7 (0)

7 (0)

12 (0)

6 (0)

19 (0)

13 (0)

Number of cylinders

4

3 (42.86% / 27.27%)

7 (100.00% / 63.64%)

0 (0% / 0%)

1 (16.67% / 9.09%)

3 (15.79% / 27.27%)

8 (61.54% / 72.73%)

6

4 (57.14% / 57.14%)

0 (0% / 0%)

0 (0% / 0%)

3 (50.00% / 42.86%)

4 (21.05% / 57.14%)

3 (23.08% / 42.86%)

8

0 (0% / 0%)

0 (0% / 0%)

12 (100.00% / 85.71%)

2 (33.33% / 14.29%)

12 (63.16% / 85.71%)

2 (15.38% / 14.29%)