R Package

From GM-RKB
Jump to navigation Jump to search

An R Package is a function library (source code) that is compatible with an R distribution.



References

2013

  • http://www.inside-r.org/r-doc/base/library
    • library and require load add-on packages.
    • Usage
      • library(package, help, pos = 2, lib.loc = NULL, character.only = FALSE, logical.return = FALSE, warn.conflicts = TRUE, quietly = FALSE, verbose = getOption("verbose"))
      • require(package, lib.loc = NULL, quietly = FALSE, warn.conflicts = TRUE, character.only = FALSE)
    • … library(package) and require(package) both load the package with name package. require is designed for use inside other functions; it returns FALSE and gives a warning (rather than an error as library() does by default) if the package does not exist. Both functions check and update the list of currently loaded packages and do not reload a package which is already loaded. (Furthermore, if the package has a namespace and a name space of that name is already loaded, they work from the existing namespace rather than reloading from the file system. If you want to reload such a package, call detach(unload = TRUE) or unloadNamespace first.)

2010

  • http://cran.r-project.org/doc/manuals/R-exts.html#Creating-R-packages
    • QUOTE: Packages provide a mechanism for loading optional code, data and documentation as needed. The R distribution itself includes about 30 packages. …

      A package is a directory of files which extend R, either a source package (the master files of a package), or a tarball containing the files of a source package, or an installed package, the result of running R CMD INSTALL on a source package. On some platforms there are also binary packages, a zip or tarball containing the files of an installed package which can be unpacked rather than installing from sources.

      A package is not[1] a library. The latter is used in two senses in R documentation. The first is a directory into which packages are installed, e.g. /usr/lib/R/library: in that sense it is sometimes referred to as a library directory or library tree (since the library is a directory which contains packages as directories, which themselves contain directories). The second sense is that used by the operating system, as a shared library or static library or (especially on Windows) a DLL, where the second L stands for `library'. Installed packages may contain compiled code in what is known on most Unix-alikes as a shared object and on Windows as a DLL (and used to be called a shared library on some Unix-alikes). The concept of a shared library (dynamic library on Mac OS X) as a collection of compiled code to which a package might link is also used, especially for R itself on some platforms.

  1. although this is common mis-usage. It seems to stem from S, whose analogues of R's packages were officially known as library sections and later as chapters, but almost always referred to as libraries.