The usePackage function takes a single command, the name of a package, and will install it, if not already installed, and then load it. Taken from https://github.com/sussyfuss/usefulScripts

Usage,
usePackage(p, repos = "http://cran.us.r-project.org")

Arguments

p

A package name as a string in quotes.

repos

Defaults to US cran otherwise put a cran mirror in as character

Examples

 usePackage("readr") 
#> Loading Package readr...
#> Loading required package: readr