instal.packages code example
Example: install package in r
#install (if not already installed) and load tseries package
if(!require(packageName)){install.packages('packageName')} else{library(packageName)}
#install (if not already installed) and load tseries package
if(!require(packageName)){install.packages('packageName')} else{library(packageName)}