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

KnitR Setup

20200602

Packages used in this chapter include diagram, dplyr, ggplot2, magrittr, xtable, Hmisc, 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(rattle)       # Dataset: weatherAUS.
library(magrittr)     # Data pipelines: %>% %T>% %<>%.
library(ggplot2)      # Visualise data.
library(xtable)       # Format R data frames as LaTeX tables.
library(Hmisc)        # Escape special LaTeX charaters.
library(diagram)      # Produce a flowchart.
library(dplyr)        # Data wrangling.
library(scales)

The rattle::weatherAUS dataset is loaded into the template variable ds and further template variables are setup as introduced in Williams (2017). See Chapter 7 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: 176,747 x 24
##    date       location min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>       <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2009-12-31 Perth        15.2     26.6      0          11.2     12.1
##  2 2014-01-16 MountGa~     22.8     44.1      0           9       12.1
##  3 2009-02-08 Sydney       21.4     28.6      0          14.2     12.2
##  4 2014-08-23 NorahHe~     10.9     17.8      8.4        NA       NA  
##  5 2014-12-07 Richmond     17.5     29.9     33.6        NA       NA  
##  6 2014-01-18 Tuggera~     14.2     39.4      0          NA       NA  
##  7 2014-07-31 Launces~     11.5     14.7     29.2        NA       NA  
....


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.