Auto install required packages in R

apt-get install libssl-dev openssl

There are more than one way to do that. The naive way could be

if (!require (package_name)) {
	install.packages (package_name)
}
library (package_name)

or you can do more nicely with the package pacman

if (!require("pacman")) install.packages("pacman")
pacman::p_load (package_1, package_2, package_2)

However, in Debian Jessie, you will need to install two libraries beforehand

sudo apt-get install libssl-dev openssl

Otherwise the installation of pacman might face to an error.

Published: November 17 2016

  • category:
blog comments powered by Disqus