28.1 KnitR Setup
20200602
Packages used in this chapter include diagram (Soetaert 2020), dplyr (Wickham, François, et al. 2026), ggplot2 (Wickham, Chang, et al. 2026), magrittr (Bache and Wickham 2026), xtable (Dahl et al. 2019), Hmisc (Harrell Jr 2026), and rattle (G. Williams 2026).
Packages are loaded into the currently running R session from your
local library directories on disk. Missing packages can be installed
using utils::install.packages() within R. On Ubuntu, for
example, R packages can also be installed using $ wajig install r-cran-<pkgname>.
# Load required packages from local library into the R session.
library(rattle) # Dataset: weatherAUS.
library(magrittr) # Data pipelines: %>% %T>% %<>%.
library(ggplot2) # Visualise data.
library(xtable) # Format R data frames as LaTeX tables.
library(Hmisc) # Escape special LaTeX charaters.
library(diagram) # Produce a flowchart.
library(dplyr) # Data wrangling.
library(scales)
library(knitr)The rattle::weatherAUS dataset is loaded into the template
variable ds and further template variables are setup as
introduced by Graham J. Williams (2017). See
Chapter 8 for details.
dsname <- "weatherAUS"
ds <- get(dsname)
nobs <- nrow(ds)
vnames <- names(ds)
ds %<>% clean_names(numerals="right")
names(vnames) <- names(ds)
vars <- names(ds)
target <- "rain_tomorrow"
vars <- c(target, vars) %>% unique() %>% rev()A random sample of the dataset:
## # A tibble: 275,410 × 24
## date location min_temp max_temp rainfall evaporation sunshine
## <date> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2014-08-18 Adelaide 6.2 14.7 0 5.2 NA
## 2 2014-10-25 Watsonia 13.2 20.9 0 7.4 5.6
## 3 2024-09-13 MountGinini -0.4 10 0.2 NA NA
## 4 2018-09-18 Canberra -2.3 20.4 0 NA NA
## 5 2020-11-07 Sydney 12.6 20.7 0 7 8.2
## 6 2011-09-06 Moree 8.5 23.5 0 4.6 10.8
## 7 2015-01-02 Tuggeranong 12.7 34.1 0 NA NA
....
References
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