This function can be useful when a package is necessary to try to answer a question on StackOverflow and you know that you won't need it anymore afterward. It will install one or several packages only for the current R session.

sopkgs(package, dependencies = TRUE, ...)

Arguments

package

character. A package name, or vector of package names.

dependencies

logical. Argument passed to install.packages. Defaults to TRUE.

...

Other arguments passed to install.packages.

Details

The files are downloaded and installed in a temporary directory, and this directory is temporarily added to the library tree within which packages are looked for: (.libPaths). If you start another R session, the package won't be accessible as it won't be in the library tree anymore, and as the files are installed in a temporary directory they should be deleted upon next reboot (this depends on your operating system).

Note

You can find alternative functions in the original question and answers on StackOverflow :

http://stackoverflow.com/questions/14896941/install-an-r-package-temporarily-only-for-the-current-session

See also

Author

Julien Barnier <julien@nozav.org>

Examples

if (FALSE) { ## Temporarily install the ggplot2 package in the current R session sopkgs("ggplot2") }