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:

# Load the package from the local library into the R session.

\usepackage{booktabs}

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
Sydney 13 30 0 6
Richmond 10 28 0 NA
MountGinini -4 -1 5 NA
Williamtown 7 18 NA NA
Penrith 12 18 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
Sydney 14 28 0 4
MountGinini 11 22 0 NA
SydneyAirport 10 22 0 3
Brisbane 14 25 0 4
Launceston 15 22 3 30
Walpole 14 26 1 NA
Adelaide 12 25 0 NA
Cobar 19 31 0 17
Brisbane 18 28 0 4
Walpole 12 18 NA NA
Ballarat 1 11 0 NA
PearceRAAF 12 20 14 NA


If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, 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