Create a table from a tibble
This is a wrapper
summary = ggplot2::diamonds %>% filter(cut %in% c("Fair","Good")) %>%
group_by(cut,color,clarity) %>%
summarise(
`average size (carat)` = sprintf("%1.2f [%1.2f \u2014 %1.2f]", mean(carat), mean(carat)-1.96*sd(carat), mean(carat)+1.96*sd(carat)),
`median price` = sprintf_list("%1.0f [%1.0f \u2014 %1.0f]", quantile(price, c(0.5,0.25,0.75)))
)
## `summarise()` has grouped output by 'cut', 'color'. You can override using the
## `.groups` argument.
table = summary %>% hux_tidy(colGroupVars = vars(cut), rowGroupVars = vars(color, clarity))
table %>% hux_default_layout(defaultFontSize = 8) %>% hux_save_as(out("multipage_t2"), std_size$third)
Fair | Good | ||||
---|---|---|---|---|---|
color | clarity | average size (carat) | median price | average size (carat) | median price |
D | I1 | 1.88 [-0.22 — 3.97] | 5538 [4718 — 8204] | 1.04 [0.11 — 1.97] | 4014 [2110 — 4754] |
SI2 | 1.02 [0.31 — 1.73] | 3473 [2478 — 4385] | 0.86 [0.09 — 1.63] | 3540 [1214 — 4458] | |
SI1 | 0.91 [0.29 — 1.54] | 3900 [2352 — 4833] | 0.70 [0.04 — 1.36] | 2318 [738 — 4786] | |
VS2 | 0.84 [0.28 — 1.41] | 4107 [2414 — 5797] | 0.70 [0.06 — 1.34] | 2768 [1203 — 5730] | |
VS1 | 0.63 [0.07 — 1.19] | 2747 [1166 — 3047] | 0.66 [0.07 — 1.25] | 2816 [988 — 5650] | |
VVS2 | 0.59 [0.04 — 1.15] | 1980 [1011 — 4040] | 0.48 [-0.01 — 0.97] | 1080 [719 — 3267] | |
VVS1 | 0.61 [-0.08 — 1.30] | 1792 [1334 — 6272] | 0.49 [-0.00 — 0.98] | 1159 [825 — 4274] | |
IF | 0.38 [0.21 — 0.55] | 1440 [1324 — 1826] | 0.79 [0.16 — 1.42] | 15081 [3378 — 15928] | |
E | I1 | 0.97 [0.56 — 1.37] | 2036 [1273 — 2571] | 1.33 [0.35 — 2.31] | 3484 [2820 — 5706] |
SI2 | 1.02 [0.29 — 1.74] | 3438 [2660 — 4511] | 0.88 [0.11 — 1.65] | 3186 [1234 — 4384] | |
SI1 | 0.87 [0.19 — 1.54] | 3508 [1383 — 4844] | 0.72 [0.02 — 1.43] | 2305 [755 — 4540] | |
VS2 | 0.69 [0.12 — 1.26] | 2508 [1127 — 4514] | 0.74 [0.13 — 1.35] | 2662 [1424 — 6056] | |
VS1 | 0.63 [-0.05 — 1.32] | 2071 [1044 — 3198] | 0.68 [0.06 — 1.30] | 2826 [1082 — 5201] | |
VVS2 | 0.60 [0.07 — 1.13] | 2079 [945 — 5430] | 0.56 [-0.12 — 1.24] | 1524 [621 — 3950] | |
VVS1 | 0.64 [-0.03 — 1.31] | 2805 [1908 — 5667] | 0.42 [-0.03 — 0.87] | 826 [564 — 1652] | |
IF | — | — | 0.37 [-0.02 — 0.77] | 912 [612 — 1053] | |
F | I1 | 1.02 [-0.06 — 2.11] | 1570 [919 — 3734] | 0.98 [0.10 — 1.85] | 2098 [1087 — 3640] |
SI2 | 1.08 [0.20 — 1.96] | 3540 [2312 — 4915] | 1.00 [0.22 — 1.78] | 3886 [2411 — 4357] | |
SI1 | 0.86 [0.15 — 1.58] | 3197 [1504 — 4646] | 0.77 [0.11 — 1.42] | 2409 [1214 — 4372] | |
VS2 | 0.76 [0.22 — 1.30] | 2762 [1402 — 4791] | 0.75 [0.09 — 1.41] | 2631 [1385 — 6032] | |
VS1 | 0.80 [0.21 — 1.40] | 3002 [2083 — 6115] | 0.62 [0.08 — 1.17] | 1780 [1136 — 3072] | |
VVS2 | 0.63 [-0.10 — 1.36] | 2286 [1043 — 4256] | 0.61 [0.01 — 1.21] | 2238 [868 — 4823] | |
VVS1 | 0.67 [-0.25 — 1.59] | 1040 [1011 — 7960] | 0.47 [-0.07 — 1.00] | 965 [680 — 2283] | |
IF | 0.55 [0.27 — 0.84] | 2502 [1900 — 2947] | 0.53 [-0.01 — 1.08] | 1806 [788 — 3186] | |
G | I1 | 1.23 [-0.02 — 2.48] | 1954 [1069 — 6315] | 1.17 [0.24 — 2.11] | 3127 [1788 — 4436] |
SI2 | 1.26 [0.24 — 2.29] | 3598 [2569 — 7956] | 1.09 [0.10 — 2.08] | 3852 [2582 — 5095] | |
SI1 | 0.91 [0.29 — 1.53] | 3145 [2032 — 4102] | 0.88 [0.09 — 1.68] | 3615 [1325 — 4708] | |
VS2 | 0.98 [0.20 — 1.76] | 4838 [2401 — 5673] | 0.82 [0.12 — 1.51] | 3947 [1348 — 5701] | |
VS1 | 0.77 [0.21 — 1.34] | 2396 [1350 — 4892] | 0.78 [0.02 — 1.54] | 3202 [926 — 6372] | |
VVS2 | 0.66 [0.02 — 1.31] | 2167 [1367 — 3323] | 0.63 [-0.03 — 1.29] | 1800 [852 — 5604] | |
VVS1 | 0.57 [0.11 — 1.03] | 2797 [1794 — 2930] | 0.55 [-0.03 — 1.13] | 1235 [816 — 3188] | |
IF | 0.46 [0.27 — 0.64] | 1488 [1308 — 1668] | 0.65 [-0.16 — 1.46] | 1706 [1004 — 5224] | |
H | I1 | 1.50 [0.06 — 2.94] | 3340 [1739 — 5995] | 1.25 [0.31 — 2.19] | 3156 [2775 — 5574] |
SI2 | 1.36 [0.37 — 2.36] | 4129 [2875 — 8810] | 1.17 [0.10 — 2.25] | 3965 [3024 — 7120] | |
SI1 | 1.11 [0.26 — 1.97] | 3816 [2591 — 6838] | 0.91 [0.01 — 1.80] | 3726 [1132 — 4840] | |
VS2 | 1.04 [0.16 — 1.92] | 3658 [2278 — 5625] | 0.88 [-0.02 — 1.78] | 3570 [991 — 5567] | |
VS1 | 0.98 [0.17 — 1.78] | 3800 [2139 — 5296] | 0.78 [-0.07 — 1.63] | 2421 [689 — 5544] | |
VVS2 | 0.84 [0.21 — 1.47] | 2717 [2554 — 4334] | 0.59 [-0.05 — 1.23] | 1821 [625 — 2699] | |
VVS1 | 0.91 [NA — NA] | 4115 [4115 — 4115] | 0.47 [-0.01 — 0.95] | 893 [684 — 1653] | |
IF | — | — | 0.94 [0.04 — 1.83] | 4554 [2163 — 8339] | |
I | I1 | 1.32 [0.34 — 2.31] | 2396 [2056 — 4956] | 1.41 [0.09 — 2.73] | 3098 [2540 — 4620] |
SI2 | 1.51 [0.33 — 2.70] | 4704 [3054 — 9610] | 1.42 [0.16 — 2.68] | 4953 [3061 — 11400] | |
SI1 | 1.11 [0.41 — 1.81] | 3308 [2856 — 4990] | 1.02 [-0.08 — 2.11] | 3382 [1033 — 8095] | |
VS2 | 0.95 [0.26 — 1.65] | 2794 [1957 — 3836] | 1.13 [0.09 — 2.17] | 4138 [2184 — 8764] | |
VS1 | 1.01 [0.05 — 1.97] | 2732 [2184 — 4281] | 0.93 [-0.04 — 1.90] | 3447 [957 — 6584] | |
VVS2 | 0.84 [0.26 — 1.43] | 2322 [2128 — 3128] | 0.72 [0.02 — 1.42] | 2309 [886 — 3401] | |
VVS1 | 0.90 [NA — NA] | 4194 [4194 — 4194] | 0.67 [-0.04 — 1.37] | 1737 [842 — 3914] | |
IF | — | — | 0.53 [-0.04 — 1.10] | 916 [695 — 2988] | |
J | I1 | 1.99 [-0.19 — 4.18] | 5405 [2313 — 6542] | 1.37 [0.39 — 2.35] | 3356 [2151 — 4999] |
SI2 | 1.32 [0.27 — 2.36] | 3302 [2736 — 5534] | 1.32 [0.27 — 2.37] | 4559 [3204 — 6421] | |
SI1 | 1.18 [0.29 — 2.07] | 3604 [2497 — 5622] | 1.13 [0.06 — 2.19] | 3672 [2016 — 6564] | |
VS2 | 1.03 [0.03 — 2.04] | 2854 [1749 — 3933] | 1.11 [0.13 — 2.10] | 3840 [1914 — 7156] | |
VS1 | 1.23 [0.19 — 2.27] | 3022 [1999 — 8193] | 0.88 [-0.14 — 1.89] | 1990 [631 — 5591] | |
VVS2 | 1.01 [NA — NA] | 2998 [2998 — 2998] | 0.94 [-0.11 — 1.99] | 3193 [1105 — 5831] | |
VVS1 | 0.70 [NA — NA] | 1691 [1691 — 1691] | 1.00 [NA — NA] | 4633 [4633 — 4633] | |
IF | — | — | 0.69 [-0.04 — 1.42] | 1557 [886 — 4534] |