9.1 Exploration Setup

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

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: 226,868 × 24
##    date       location      min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>            <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2014-07-21 Woomera            4.5     18        0          46.2     NA  
##  2 2017-09-26 Hobart             4.1     14.5      0.4         2.8      8.9
##  3 2020-04-28 NorfolkIsland     16.7     23.4      0           3.4     NA  
##  4 2013-05-04 Townsville        19.4     29.3      0           7.4     10.6
##  5 2021-05-31 Cobar              3.9     20.8      0          NA       NA  
##  6 2012-06-03 Williamtown       14.1     16.3     NA          NA       NA  
##  7 2018-01-18 Hobart            12.1     31.2      0           6        9.1
##  8 2010-05-15 Moree              3.4     23.4      0           5.4     10  
##  9 2013-09-20 Walpole           11.4     16.1      6.8        NA       NA  
## 10 2014-05-19 Tuggeranong        4       20.2      0          NA       NA  
## # ℹ 226,858 more rows
....

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. 2023. 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