25.12 Formatting Options

REVIEW Formatting options are available for fine tuning how the table is to be presented. For example we can remove the row names (the row numbers in the above table) easily with row.names=FALSE.

# Display a table without row names.

ds %>% kable(row.names=FALSE)
Location MinTemp MaxTemp Rainfall Evaporation
Canberra -5.4 13.2 0.0 NA
Williamtown 8.4 17.6 0.0 NA
Portland 12.7 23.1 1.4 4.2
Ballarat 7.0 11.1 1.0 NA
SydneyAirport 6.9 15.4 0.0 3.8

We can also limit the number of digits displayed to avoid an impression of a high level of accuracy or to simplify presentation using digits=. By doing so the numeric values are rounded to the requested number of decimal points.

# Display a table removing digits from numbers.

ds %>% kable(row.names=FALSE, digits=0)
Location MinTemp MaxTemp Rainfall Evaporation
Canberra -5 13 0 NA
Williamtown 8 18 0 NA
Portland 13 23 1 4
Ballarat 7 11 1 NA
SydneyAirport 7 15 0 4


Your donation will support ongoing development 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.