28.13 Improvements Using BookTabs
REVIEW The booktabs package for
LaTeX provides additional functionality that we can make use of
with knitr::kable(). To use this be sure to include the
following in the preamble (before the \begin{document} of your
.Rnw file:
We can then set booktabs=TRUE to remove the clutter
of the extra lines.
# Use the booktabs option to improve presentation of the table.
ds %>% kable(row.names=FALSE, digits=0, booktabs=TRUE)| Location | MinTemp | MaxTemp | Rainfall | Evaporation |
|---|---|---|---|---|
| Williamtown | 12 | 17 | 20 | 1 |
| SydneyAirport | 14 | 18 | 8 | 2 |
| MelbourneAirport | 21 | 34 | 0 | 14 |
| Canberra | 16 | 26 | 7 | NA |
| Richmond | 2 | 20 | 0 | NA |
In the following example we notice that with more rows
booktabs=TRUE will add a small gap every 5 rows.
# Display a tale with more observations.
weatherAUS[sample(nobs, 12), vars] %>%
kable(row.names=FALSE, digits=0, booktabs=TRUE)| Location | MinTemp | MaxTemp | Rainfall | Evaporation |
|---|---|---|---|---|
| PearceRAAF | 10 | 27 | 0 | NA |
| Townsville | 19 | 28 | 0 | 10 |
| Williamtown | 13 | 31 | 0 | 8 |
| Canberra | 6 | 32 | 0 | NA |
| MelbourneAirport | 10 | 18 | 0 | 2 |
| Cairns | 23 | 29 | 4 | NA |
| Williamtown | 15 | 24 | 0 | 4 |
| Woomera | 15 | 29 | 0 | 12 |
| WaggaWagga | 17 | 36 | 0 | 10 |
| SydneyAirport | 10 | 24 | 0 | 2 |
| PerthAirport | 25 | 37 | 0 | 11 |
| Cobar | 9 | 18 | 7 | NA |
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0