9.1 Exploration Setup

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

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: 198,656 × 24
##    date       location      min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>            <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2020-02-06 Uluru             21.8     39.2      0          NA       NA  
##  2 2015-04-13 NorfolkIsland     16.6     23.1     19.8        NA        8.6
##  3 2014-05-09 Cobar             11       21.5      0           5.8     NA  
##  4 2011-03-12 SydneyAirport     20.7     28.2      1.6         3.2      9.8
##  5 2020-09-24 Albany            12.9     16.8      0           8.2     NA  
##  6 2021-06-16 Sydney             8.8     20.2      0           1.6      7.4
##  7 2015-02-24 Dartmoor           7       21.1      0           6.2     12  
##  8 2021-04-01 Walpole           18.1     23.9      3.6        NA       NA  
##  9 2016-01-06 NorfolkIsland     19.6     24.5      1.6         5.8      0.3
## 10 2015-01-18 Townsville        26       34.9      3           5.2      4.4
## # … with 198,646 more rows, and 17 more variables: wind_gust_dir <ord>,
## #   wind_gust_speed <dbl>, wind_dir_9am <ord>, wind_dir_3pm <ord>,
## #   wind_speed_9am <dbl>, wind_speed_3pm <dbl>, humidity_9am <int>,
## #   humidity_3pm <int>, pressure_9am <dbl>, pressure_3pm <dbl>,
## #   cloud_9am <int>, cloud_3pm <int>, temp_9am <dbl>, temp_3pm <dbl>,
## #   rain_today <fct>, risk_mm <dbl>, rain_tomorrow <fct>

References

Bache, Stefan Milton, and Hadley Wickham. 2020. Magrittr: A Forward-Pipe Operator for r. https://CRAN.R-project.org/package=magrittr.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2021. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.
Williams, Graham. 2021. 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-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0