Huxtable is a package for creating text tables. It is powerful, but easy to use. Huxtable’s features include
- Export to LaTeX, HTML, Microsoft Word, Microsoft Excel, Microsoft Powerpoint, RTF and Markdown,
- Easy integration with knitr and rmarkdown documents
- Formatted on-screen display,
- Multirow and multicolumn cells,
- Fine-grained control over cell background, spacing, alignment, size and borders,
- Control over text font, style, size, color, alignment, number format and rotation,
- Table manipulation using standard R subsetting, or dplyr functions like filter and select,
- Easy conditional formatting based on table contents,
- Quick table themes,
- Automatic creation of regression output tables with the huxreg function
year | continent | country | lifeExp | pop | gdpPercap |
2002 | Asia | Afghanistan | 42.1 | 25268405 | 727 |
Europe | Albania | 75.7 | 3508512 | 4.6e+03 |
Africa | Algeria | 71 | 31287142 | 5.29e+03 |
Angola | 41 | 10866106 | 2.77e+03 |
Americas | Argentina | 74.3 | 38331121 | 8.8e+03 |
Oceania | Australia | 80.4 | 19546792 | 3.07e+04 |
Getting started with huxtable
Pots of jam for sale
Type | Price |
Strawberry | 1.90 |
Raspberry | 2.10 |
Plum | 1.80 |
reshaping
Restacked down
1 | 5 |
2 | 6 |
9 | 13 |
10 | 14 |
3 | 7 |
4 | 8 |
11 | 15 |
12 | 16 |
Table position and column width
| Sepal | Petal | | Sepal | Petal | | Sepal | Petal |
Species | Length | Width | Length | Width | Species | Length | Width | Length | Width | Species | Length | Width | Length | Width |
setosa | 5.1 | 3.5 | 1.4 | 0.2 | versicolor | 7 | 3.2 | 4.7 | 1.4 | virginica | 6.3 | 3.3 | 6 | 2.5 |
setosa | 4.9 | 3 | 1.4 | 0.2 | versicolor | 6.4 | 3.2 | 4.5 | 1.5 | virginica | 5.8 | 2.7 | 5.1 | 1.9 |
setosa | 4.7 | 3.2 | 1.3 | 0.2 | versicolor | 6.9 | 3.1 | 4.9 | 1.5 | virginica | 7.1 | 3 | 5.9 | 2.1 |
setosa | 4.6 | 3.1 | 1.5 | 0.2 | versicolor | 5.5 | 2.3 | 4 | 1.3 | virginica | 6.3 | 2.9 | 5.6 | 1.8 |
setosa | 5 | 3.6 | 1.4 | 0.2 | versicolor | 6.5 | 2.8 | 4.6 | 1.5 | virginica | 6.5 | 3 | 5.8 | 2.2 |
Themes
Most populous Countries, 2002
country | continent | lifeExp | pop | gdpPercap |
China | Asia | 72 | 1280400000 | 3.12e+03 |
India | Asia | 62.9 | 1034172547 | 1.75e+03 |
United States | Americas | 77.3 | 287675526 | 3.91e+04 |
Indonesia | Asia | 68.6 | 211060000 | 2.87e+03 |
Brazil | Americas | 71 | 179914212 | 8.13e+03 |
Pakistan | Asia | 63.6 | 153403524 | 2.09e+03 |
Bangladesh | Asia | 62 | 135656790 | 1.14e+03 |
Japan | Asia | 82 | 127065841 | 2.86e+04 |
Nigeria | Africa | 46.6 | 119901274 | 1.62e+03 |
Mexico | Americas | 74.9 | 102479927 | 1.07e+04 |
jams %>%
set_all_padding(4) %>%
set_outer_padding(0) %>%
set_number_format(2) %>%
set_bold(1, everywhere) %>%
set_bottom_border(1, everywhere) %>%
set_width(0.4) %>%
set_caption("Pots of jam for sale")
Pots of jam for sale
Type | Price |
Strawberry | 1.90 |
Raspberry | 2.10 |
Plum | 1.80 |
Using assignment
embed_flipbook("hux_set", font_size = 120,
use_embed_xaringan = T,
left_assign = T,
widths = c(4.5,3),
use_share_again = T)