Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go

Dataset Setup

20200320 Packages used in this chapter include dplyr, janitor, magrittr, randomForest, and rattle.

Packages are loaded into the current R session from the local library directories on disk. Missing packages can be installed using utils::install.packages() within R. On Ubuntu R packages can 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(janitor)      # Cleanup: clean_names().
library(magrittr)     # Data pipelines: %>% %<>% %T>% equals().
library(randomForest) # Model: randomForest() na.roughfix() for missing data.
library(rattle)       # normVarNames(). Dataset: weather.

After loading the required packages into the library we access the rattle::weatherAUS dataset and save it into the template dataset named ds, as per the template based approach introduced in Williams (2017). The dataset is reasonably large ( rows or observations by columns or variables) and is used extensively in this book to illustrate the capabilities of R for the Data Scientist.

# Initialise the dataset as per the template.
dsname <- "weatherAUS"
ds     <- get(dsname)

ds %>% sample_frac()
## # A tibble: 176,747 x 24
##    Date       Location MinTemp MaxTemp Rainfall Evaporation Sunshine
##    <date>     <chr>      <dbl>   <dbl>    <dbl>       <dbl>    <dbl>
##  1 2013-07-24 Brisbane     7.9    21.3      0           4.8      9.8
##  2 2011-06-08 Perth        6      19.9      0           2.2      9.2
##  3 2009-02-16 SydneyA~    17.8    24.6     16.6         4.8      6.4
##  4 2011-12-31 Albany      18.9    22.5      1.2         1.4      0.2
##  5 2018-02-19 Mildura     19.8    32.8      0.2        15.6     NA  
##  6 2011-01-22 Sale        16.5    22.1      0.4         6.8      0.1
##  7 2013-10-10 Watsonia    14.8    16.6      0          10.2      0.9
##  8 2015-12-06 MountGi~    11.3    23.5      0          NA       NA  
##  9 2014-09-02 Bendigo      3.5    14.6      9.6        NA       NA  
## 10 2018-09-22 Cairns      21.7    28.4     NA          NA       NA  
## # ... with 176,737 more rows, and 17 more variables: WindGustDir <ord>,
## #   WindGustSpeed <dbl>, WindDir9am <ord>, WindDir3pm <ord>,
## #   WindSpeed9am <dbl>, WindSpeed3pm <dbl>, Humidity9am <int>,
## #   Humidity3pm <int>, Pressure9am <dbl>, Pressure3pm <dbl>, Cloud9am <i...
## #   Cloud3pm <int>, Temp9am <dbl>, Temp3pm <dbl>, RainToday <fct>,
## #   RISK_MM <dbl>, RainTomorrow <fct>


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.