--- title: "What does `library()` do?" author: "Martin Maechler" date: "April 2016" output: html_document --- ### What happens when you "get" a package: `library()` etc ``` require() \ 1) load the namespace corresponding to 'pkg' \ -> *import* (*recursively*) everything needed / 2) attach "the package" to the search() path. library() / "the package" := The *export*ed objects ``` ### Every Package has two important "Meta data" files: * `DECRIPTION`: contains `Depends:`, `Imports:`, ... * `NAMESPACE`: has `imports()` and `exports()` (plus `S3methods()`, `exportClasses()`, ...) ### R functions related to this: * `loadNamespace` * `::` ( and also `:::` ) * `sessionInfo()` * `getAnywhere()`