Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Formatting Options

Raw 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
Tuggeranong 10.0 25.1 0.2 NA
Wollongong 20.8 30.7 1.0 NA
Dartmoor 5.7 14.9 1.6 2.6
Sale 16.8 28.8 0.0 6.0
WaggaWagga 7.7 31.3 0.0 4.0

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
Tuggeranong 10 25 0 NA
Wollongong 21 31 1 NA
Dartmoor 6 15 2 3
Sale 17 29 0 6
WaggaWagga 8 31 0 4

NOT QUITE WORKING YET - STILL WANT COLUMN TREATED AS NUMERIC.

We can the remove the missing values (recorded as NA) with a simple stringr::str_replace().

ds %>% replace(is.na(.), "") %>% kable(row.names=FALSE, digits=0)

## Error: Assigned data `values` must be compatible with existing data.
## i Error occurred for column `Evaporation`.
## x Can't convert <character> to <double>.


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.