Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/calligross/reinstallr
Reinstall missing R packages
https://github.com/calligross/reinstallr
Last synced: 8 days ago
JSON representation
Reinstall missing R packages
- Host: GitHub
- URL: https://github.com/calligross/reinstallr
- Owner: calligross
- Created: 2016-05-11T19:14:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-11-27T08:13:32.000Z (about 3 years ago)
- Last Synced: 2024-11-29T09:38:48.902Z (13 days ago)
- Language: R
- Size: 24.4 KB
- Stars: 49
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - calligross/reinstallr - Reinstall missing R packages (R)
README
reinstallr
==============[![R-CMD-check](https://github.com/calligross/reinstallr/workflows/R-CMD-check/badge.svg)](https://github.com/calligross/reinstallr/actions)
[![CRAN](http://www.r-pkg.org/badges/version/reinstallr)](http://cran.rstudio.com/package=reinstallr) [![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/reinstallr?color=brightgreen)](http://www.r-pkg.org/pkg/reinstallr)`reinstallr` is a tool to identify missing packages, e.g. after upgrading R, by scanning through your R files. If the missing packages are available on CRAN and you confirmed the install, `install.packages` is called. As a bonus, it provides some information about the packages you are using.
`reinstallr` is a little helper I wrote for myself and I'm glad if it's useful for anyone else. **Pull requests to improve the package are very welcomed!**
`reinstallr` searches for
* `library()`,
* `require()` and
* `package::function`/`package:::function` calls.Installation
------------`reinstallr` is available on CRAN (stable) or via `devtools::install_github` (dev)
```r
install.packages('reinstallr')
``````r
if (!requireNamespace("devtools", quietly = TRUE))
install.packages("devtools")devtools::install_github("calligross/reinstallr")
```Usage
------------```r
reinstallr(path = NULL, pattern = NULL, ...)
```Per default reinstallr searches the working directory for R, Rmd, Rnw, Rhtml and Rpres files. After a reinstall the following might be enough to install all packages (from CRAN):
```r
# All my R projects are located in ~/Documents/R/
reinstallr(path = '~/Documents/R/')```
`show_missing_packages()` searches for missing packages and checks if the package is available on CRAN:
```r
show_missing_packages(path = '~/Documents/R/')
# package on_cran
# 1 lineprof FALSE
# 2 BuBa FALSE
# 3 metricsgraphics TRUE
```If you would like to find out, which packages you use, `show_package_stats()` is your friend:
```r
show_package_stats(path = '~/Documents/R/')
# [...]
# 43 testthat 3
# 44 htmltools 4
# 45 lubridate 4
# 46 reshape2 4
# 47 twitteR 4
# 48 data 5
# 49 rstudioapi 5
# 50 scales 5
# 51 jsonlite 7
# 52 dplyr 10
# 53 knitr 11
# 54 htmlwidgets 12
# 55 ggplot2 17
# 56 rhandsontable 17
# 57 microbenchmark 18
# 58 shiny 34
````find_used_packages()` gives you the information, in which files a package is used:
```r
find_used_packages(packages = c('dplyr', 'ggplot2'), path = '~/Documents/R/')
```