Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joshkatz/needs

An R function for safe package loading / installation.
https://github.com/joshkatz/needs

Last synced: 8 days ago
JSON representation

An R function for safe package loading / installation.

Awesome Lists containing this project

README

        

# needs
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/needs)](http://cran.r-project.org/package=needs)

`needs` is a simple R package to make package loading / installation hassle-free — use it in place of `library` to attach packages and automatically install any that are missing. You can also supply a minimum version number, and it will update old packages as needed. No more changing your code to reinstall packages every time you update R — `needs` does it for you.

```r
install.packages("needs")
# for the dev version:
# devtools::install_github("joshkatz/needs", ref = "development")
library(needs)

# answer "yes" when prompted, and you will never have
# to type library or install.packages again. hooray.
```

### Usage
Once installed, use just as you would `library`. With the added bonus of being able to give multiple unquoted arguments in one single function call. Specify a required package version with a pairlist:

```r
needs(foo,
bar = "0.9.1",
baz = "0.4.3")
```

### Rprofile
`needs` can help make code-sharing easier. In your project directory:

```r
needs::toProfile()
```
This extracts the package contents and appends it to the Rprofile in your working directory. Now if someone else clones your project, your code runs without requiring any extra installation or throwing errors for uninstalled packages.