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

Strings Setup

20180720 Packages used in this chapter include dplyr, glue, magrittr, stringr, stringi, scales, 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: mutate().
library(stringi)      # The string concat operator %s+%.
library(stringr)      # String manipulation.
library(glue)         # Format strings.
library(magrittr)     # Pipelines for data processing: %>% %T>% %<>%.
library(rattle)       # Weather dataset.
library(scales)       # commas(), percent().

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 modestly large 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)
names(ds) %<>% normVarNames()

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 2017-08-03 CoffsHa~      4.6     19.9      0          NA       NA  
##  2 2015-03-01 Hobart       13.3     19.6      1.6         3.4      9.5
##  3 2013-01-04 Woomera      23.9     46.1      0          NA       NA  
##  4 2009-11-23 Cairns       22.2     30.1      1           5.8     10.7
##  5 2019-08-11 PearceR~     11.3     22.7      0          NA        9.8
##  6 2020-04-16 Launces~     13.1     18.8      3.6        NA       NA  
##  7 2013-03-22 MountGi~      7.5     13       32.2        NA       NA  
##  8 2010-07-30 Brisbane     15.3     26.4      0           0.2      8  
##  9 2009-12-14 Melbour~     13.2     19.8      0           4.6     11.3
## 10 2008-08-15 Melbour~      9.9     14.2      0.2         2.2      1.4
## # ... with 176,737 more rows, and 17 more variables: wind_gust_dir <ord>,
## #   wind_gust_speed <dbl>, wind_dir_9am <ord>, wind_dir_3pm <ord>,
....


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.