7.1 Data Creation Setup
20201022 Packages used in this chapter include dplyr (Wickham, François, et al. 2023), magrittr (Bache and Wickham 2022), randomForest (Breiman et al. 2022), readxl (Wickham and Bryan 2023), wakefield (Rinker 2020b), xlsx (Dragulescu and Arendt 2020), and rattle (G. Williams 2020).
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(randomForest) # Model: randomForest() na.roughfix() for missing data. library(readr) # Read/write delimited data: read_csv(). library(readxl) # Read Excel spreadsheets: read_excel(). library(wakefield) # Generate random datasets. library(xlsx) # Write Excel spreadsheets: write.xlsx() saveWorkbook(). library(rattle) # Dataset: weather.
After loading the required packages into the library we access the
rattle::weatherAUS dataset and save it into the template
ds, as per the template based approach
introduced in Graham J. 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. <- weatherAUS ds %>% sample_frac()ds
## # A tibble: 176,747 × 24 ## Date Location MinTemp MaxTemp Rainfall Evaporation Sunshine WindGustDir ## <date> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <ord> ## 1 2019-11-11 William… 11.3 26.5 0 NA NA ENE ## 2 2018-07-17 Launces… 5.6 15 4.4 NA NA N ## 3 2018-03-28 Penrith 14.2 30 0 NA NA ENE ## 4 2009-08-16 Richmond 0.9 26.6 0 NA NA NNE ## 5 2019-01-14 WaggaWa… 22.8 42 NA NA NA E ## 6 2011-07-17 Wollong… 10.1 15.8 1 NA NA WNW ## 7 2013-09-29 Watsonia 4.1 20.3 0.2 4.2 9.3 NNW ....
Your donation will support ongoing availability 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-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0