9.1 Exploration Setup

20200317 Packages used in this chapter include dplyr (Wickham, François, et al. 2026), magrittr (Bache and Wickham 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(dplyr)        # Wrangling: select() sample_frac().
library(magrittr)     # Data pipelines: %>% %<>% %T>% equals().
library(rattle)       # normVarNames(). Dataset: weather.

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:

ds %>% sample_frac()
## # A tibble: 275,410 × 24
##    date       location      min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>            <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2014-05-25 SalmonGums        10.3     18.4      1.2        NA       NA  
##  2 2009-11-24 Cairns            21.6     31        0           6.2      7.3
##  3 2018-12-19 NorahHead         21.2     24.1      0          NA       NA  
##  4 2024-02-03 Portland           7.3     23.7      0.2        NA       NA  
##  5 2009-08-11 SydneyAirport      9.2     18.2      0           1.2      2.4
##  6 2010-06-28 Albany            10.5     15.3      4.8         1.4      2.6
##  7 2014-12-17 CoffsHarbour      22.3     34.5      2.6        NA       NA  
##  8 2021-04-07 Williamtown       17.6     24.8      6.2        NA       NA  
##  9 2018-06-18 Wollongong         9.5     15.7      4          NA       NA  
## 10 2014-05-26 Canberra           5.6     21.7      0          NA       NA  
## # ℹ 275,400 more rows
....

References

Bache, Stefan Milton, and Hadley Wickham. 2026. Magrittr: A Forward-Pipe Operator for r. https://magrittr.tidyverse.org.
Wickham, Hadley, Romain François, Lionel Henry, Kirill Müller, and Davis Vaughan. 2026. Dplyr: A Grammar of Data Manipulation. https://dplyr.tidyverse.org.
Williams, Graham. 2026. Rattle: R Data Science Supporting Rattle. https://togaware.com/projects/rattle/.
Williams, Graham J. 2017. The Essentials of Data Science: Knowledge Discovery Using r. The r Series. CRC Press.


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