26.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
Wollongong 15 23 0 NA
Williamtown 22 28 0 6
Mildura 6 20 0 8
MountGinini 1 8 0 NA
SydneyAirport 22 30 0 5

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
Hobart 2 14 0 2
Albany 12 18 0 3
Wollongong 15 20 1 NA
MountGinini -1 6 0 NA
Nhil 7 19 0 NA
Nuriootpa 6 18 0 2
Canberra 4 22 0 6
Perth 1 18 0 2
Wollongong 10 15 14 NA
Williamtown 14 30 0 NA
AliceSprings 21 38 0 12
CoffsHarbour 9 18 0 4


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-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0