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

Simplifying Commands

REVIEW By attaching the dplyr package we can drop the package name prefix for any commands from the package. Similarly by attaching rattle we can drop the package name prefix from the name of the dataset. Our previous tibble::glimpse() command can be simplified.
# Review the dataset.

glimpse(x=weatherAUS)
## Rows: 176,747
## Columns: 24
## $ Date          <date> 2008-12-01, 2008-12-02, 2008-12-03, 2008-12-04, 2...
## $ Location      <chr> "Albury", "Albury", "Albury", "Albury", "Albury", ...
## $ MinTemp       <dbl> 13.4, 7.4, 12.9, 9.2, 17.5, 14.6, 14.3, 7.7, 9.7, ...
## $ MaxTemp       <dbl> 22.9, 25.1, 25.7, 28.0, 32.3, 29.7, 25.0, 26.7, 31...
....

We can actually simplify this a little more. Often for a command we don't have to explicitly name all of the arguments. In the following example we drop the package= and the x= arguments as the commands themselves know what to expect implicitly.

# Load packages from the local library into the R session.

library(dplyr)
library(rattle)

# Review the dataset.

glimpse(weatherAUS)
## Rows: 176,747
## Columns: 24
## $ Date          <date> 2008-12-01, 2008-12-02, 2008-12-03, 2008-12-04, 2...
## $ Location      <chr> "Albury", "Albury", "Albury", "Albury", "Albury", ...
## $ MinTemp       <dbl> 13.4, 7.4, 12.9, 9.2, 17.5, 14.6, 14.3, 7.7, 9.7, ...
## $ MaxTemp       <dbl> 22.9, 25.1, 25.7, 28.0, 32.3, 29.7, 25.0, 26.7, 31...
....

A number of packages are automatically attached when R starts. The first base::search() command above returned a vector of packages and since we had yet to attach any further packages those listed are the ones automatically attached. One of those is the base package which provides the base::library() command.


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.