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

Attaching a Package

REVIEW We can attach a package to our current R session from our local library for added convenience. This will make the command available during this specific R session without the requirement to specify the package name each time we use the command. Attaching a package tells the R software to look within that package (and then to look within any other attached packages) when it needs to find out what the command should do (the definition of the command). We can see which packages are currently attached using base::search(). The order in which they are listed here corresponds to the order in which R searches for the definition of a command.
base::search()
##  [1] ".GlobalEnv"        "package:stats"    
##  [3] "package:graphics"  "package:grDevices"  
##  [5] "package:utils"     "package:datasets"  
##  [7] "package:methods"   "Autoloads" 
##  [9] "package:base"

Notice that a collection of packages are installed by default among a couple of other special objects (.GlobalEnv and Autoloads). A package is attached using the base::library() command. The base::library() command takes an argument to identify the package= we wish to attach.

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

library(package=dplyr)
library(package=rattle)

Running these two commands will affect the search path by placing these packages early within the path.

base::search()
##  [1] ".GlobalEnv"        "package:rattle"
##  [3] "package:dplyr"     "package:stats"    
##  [5] "package:graphics"  "package:grDevices"  
##  [7] "package:utils"     "package:datasets"  
##  [9] "package:methods"   "Autoloads" 
## [11] "package:base"


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.