R Location Of Packages

Posted on by admin
R Location Of Packages Rating: 4,9/5 7452 votes

The release of the leaflet package in 2015 revolutionized interactive web map creation from within R and a number of packages have built on these foundations adding new features (e.g., leaflet.extras) and making the creation of web maps as simple as creating static maps (e.g., mapview and tmap). This section illustrates each approach in the. R also has a default value for a directory where users can install their own R packages. On the Owens cluster, it is /R/x8664-unknown-linux-gnu-library/3.3 if the default R-3.3.2 module is loaded. This directory doesn't exist by default. The first time a user installs an R package, R will ask the user if s/he wants to use the default location.

[This article was first published on R – Quintuitive, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Recently, while working on the Azure Data Lake R extension, I had to figure out a good way to create a zip file containing a package together with all its dependencies. This came down to understanding where does R store and search for packages. Despite the documentation, it did require additional reading and experimentation.

First, the accompanying video:

Location

Before getting into package search paths, let’s first figure out how does an R package look in the file system:

An R package is a folder somewhere in the file system. Above quantmod, TTR, xts and zoo are all folders each containing the corresponding package. For these packages to be found by R, the rsite folder (its absolute path, for instance c:/users/ivannp/rsite) needs to be added to R’s search path.

R’s package search path is reported by the .libPaths() function (invoked without arguments). The result is a vector of strings, each representing a path containing packages. When the user requests a package to be loaded (via require or via library), R searches for the package in each path of the list, starting with the first. If the package is found, it is loaded and the search finishes. Thus, it is important to understand how the vector of paths is build.

The last element of the path is R’s distribution library path. On Windows this could be:

This path cannot be removed. Calling .libPaths(”) (with an empty string) will remove all other entries but the library sub-directory of the distribution.

There are three environment variables which control the content of the path vector:

  • R_LIBS
  • R_LIBS_USER
  • R_LIBS_SITE

The content of these environment variables is added to the package search path in the order listed. First R_LIBS, then R_LIBS_USER and finally R_LIBS_SITE.

If none of the three environment variables is defined, R will append a default path to the search list. This path is platform dependent. On Windows it is something like:

To avoid depending on this behavior, I typically have R_LIBS_USER set. On Windows, make sure that the path doesn’t end with slash (‘/’ or ‘’). According to .libPaths() documentation, paths ending on a slash are invalid, and R silently ignores them.

Will all this knowledge, the solution to the original problem – how to create a zip containing a package together with all its dependencies, is clear:

The above script create packages.zip containing ggplot2 and all its dependencies. A local folder packages is used in the process. That’s assuming there are no additional packages in R’s root installation.

The post Package Paths in R appeared first on Quintuitive.

To leave a comment for the author, please follow the link and comment on their blog: R – Quintuitive.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job. Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Available Packages

Currently, the CRAN package repository features 17052 available packages.

Installation of Packages

Please type help('INSTALL')or help('install.packages')in R for information on how to install packages from thisrepository. The manualR Installation and Administration(also contained in the R base sources)explains the process in detail.

R Location Of Packages

CRAN Task Viewsallow you to browse packages by topic and provide tools toautomatically install all packages for special areas ofinterest.Currently, 41 views are available.

R Location Of Packages Us Postal Service

Package Check Results

R Location Of Packages

R Location Of Packages Around The World

All packages are tested regularly on machines runningDebian GNU/Linux,Fedora,macOS (formerly OS X), Solaris and Windows.

The results are summarized in thecheck summary (sometimings are also available).Additional details for Windows checking and building can befound in theWindowscheck summary.

Writing Your Own Packages

The manualWriting R Extensions(also contained in the R base sources) explains how to writenew packages and how to contribute them to CRAN.

Repository Policies

The manualCRAN Repository Policy[PDF]describes the policies in place for the CRAN package repository.

R Package Path

Related Directories

R Change Library Path

Archive
Previous versions of the packages listed above, and other packages formerly available.
Orphaned
Packages with no active maintainer, see the corresponding README.
bin/windows/contrib
Windows binaries of contributed packages
bin/macosx/contrib
macOS High Sierra binaries of contributed packages
bin/macosx/el-capitan/contrib
OS X El Capitan binaries of contributed packages