9.1 Exploration Setup
20200317 Packages used in this chapter include dplyr (Wickham 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.
<- "weatherAUS"
dsname <- get(dsname)
ds
<- nrow(ds)
nobs
<- names(ds)
vnames %<>% clean_names(numerals="right")
ds names(vnames) <- names(ds)
<- names(ds)
vars <- "rain_tomorrow"
target <- c(target, vars) %>% unique() %>% rev() vars
A random sample of the dataset:
%>% sample_frac() ds
## # A tibble: 191,431 x 24
## date location min_temp max_temp rainfall evaporation sunshine
## <date> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2019-01-05 NorfolkIsland 19.5 26.2 0 7.8 NA
## 2 2015-03-11 Cobar 21.9 35.2 0 11.6 NA
## 3 2015-10-02 SydneyAirport 16.9 23.5 0 4.8 10.5
## 4 2012-03-03 PearceRAAF 18.3 33.1 0 NA 11.3
## 5 2013-06-09 SydneyAirport 11.1 20.5 0 7 6.9
## 6 2014-10-22 Brisbane 16.6 25.5 0 7.8 9.2
## 7 2014-10-09 Launceston 6.2 18.1 1 NA NA
## 8 2019-09-30 NorfolkIsland 17.6 20.7 3.4 3.2 NA
## 9 2017-06-23 Adelaide 5.4 18.5 0 NA NA
## 10 2010-07-17 Townsville 13.3 25.3 0 6.4 10.7
## # … with 191,421 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>
Your donation will support ongoing development 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.