9.1 Exploration Setup

20200317 Packages used in this chapter include dplyr (Wickham, François, et al. 2023), magrittr (Bache and Wickham 2022), and rattle (G. Williams 2022).

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: 217,049 × 24
##    date       location   min_t…¹ max_t…² rainf…³ evapo…⁴ sunsh…⁵ wind_…⁶ wind_…⁷
##    <date>     <chr>        <dbl>   <dbl>   <dbl>   <dbl>   <dbl> <ord>     <dbl>
##  1 2011-08-08 Launceston     3.5    12.9     1.2    NA      NA   SSE          43
##  2 2022-03-22 NorahHead     17.2    28       0      NA      NA   NNE          44
##  3 2012-01-13 Cobar         15.3    29.2     0      10      NA   SSW          31
##  4 2012-10-22 Sydney        15.1    18.7     0       6       6.6 SSE          80
##  5 2021-02-04 MountGamb…    12.4    26.7     0      NA      NA   NW           43
##  6 2010-05-31 Sydney        12.6    20      12.8     1.6     3.9 <NA>         NA
##  7 2011-08-01 Portland       9.4    18.5     0       2.8     5.5 NW           61
##  8 2021-09-30 AliceSpri…    12.2    31       0      NA      NA   SW           48
##  9 2014-09-02 PerthAirp…    12.8    20.8     0       4.2     0   ENE          30
## 10 2009-04-19 NorfolkIs…    18.7    22.5    17.2     0.8     7.8 W            35
## # … with 217,039 more rows, 15 more variables: wind_dir_9am <ord>,
....

References

Bache, Stefan Milton, and Hadley Wickham. 2022. Magrittr: A Forward-Pipe Operator for r. https://CRAN.R-project.org/package=magrittr.
Wickham, Hadley, Romain François, Lionel Henry, Kirill Müller, and Davis Vaughan. 2023. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.
Williams, Graham. 2022. Rattle: Graphical User Interface for Data Science in r. https://rattle.togaware.com/.
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