2.8 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 stringi::search(). The order in which they are listed here corresponds to the order in which R searches for the definition of a command.
##  ".GlobalEnv" "package:stats" ##  "package:graphics" "package:grDevices" ##  "package:utils" "package:datasets" ##  "package:methods" "Autoloads" ##  "package:base"
Notice that a collection of packages are installed by
default among a couple of other special objects (
# 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.
##  ".GlobalEnv" "package:rattle" ##  "package:dplyr" "package:stats" ##  "package:graphics" "package:grDevices" ##  "package:utils" "package:datasets" ##  "package:methods" "Autoloads" ##  "package:base"
Your donation will support ongoing development 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-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.