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



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Dataset Setup

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

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 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: 3,984 x 24
##    Date                Location MinTemp MaxTemp Rainfall Evaporation Sun...
##    <dttm>              <chr>      <dbl>   <dbl>    <dbl>       <dbl>    ...
##  1 2015-01-28 00:00:00 Sydney      17.3    20.5     57           7.2    ...
##  2 2019-12-21 00:00:00 Sydney      21.1    28.7      0           8.6    ...
##  3 2014-04-06 00:00:00 Sydney      17.2    21.7      3.4         4.6    ...
##  4 2015-09-23 00:00:00 Sydney      10      16.2      0.2         8.8    ...
##  5 2011-01-19 00:00:00 Sydney      19.3    25.4      7.2         5.6    ...
##  6 2015-05-09 00:00:00 Sydney      11.4    21        0           2.8    ...
##  7 2009-12-18 00:00:00 Sydney      20.2    21.4      5.4        13.6    ...
##  8 2015-11-10 00:00:00 Sydney      15.2    25.6      0           6      ...
##  9 2011-05-10 00:00:00 Sydney      10.1    18        4.4         3.4    ...
## 10 2008-06-21 00:00:00 Sydney      11.6    18.5      2.2         1.8    ...
## # ... with 3,974 more rows, and 17 more variables: WindGustDir <chr>,
## #   WindGustSpeed <dbl>, WindDir9am <chr>, WindDir3pm <chr>,
## #   WindSpeed9am <dbl>, WindSpeed3pm <dbl>, Humidity9am <dbl>,
## #   Humidity3pm <dbl>, Pressure9am <dbl>, Pressure3pm <dbl>, Cloud9am <d...
## #   Cloud3pm <dbl>, Temp9am <dbl>, Temp3pm <dbl>, RainToday <chr>,
## #   RISK_MM <dbl>, RainTomorrow <chr>


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.