R/packages.r

Defines functions packages

Documented in packages

#' load add-on packages. If the packages can not be found, install.packages is called.
#' @name packages
#' @aliases packages
#' @title load packages with auto-installation
#' @param x name of the packages
#' @param ... arguments to install.packages
#' @author TszKin Julian Chan \email{ctszkin@@gmail.com}
#' @seealso \link{require}  \link{install.packages}
#' @export
#' @examples     
#' \dontrun{
#' packages("foreach")
#' }
packages<-function(x,...){
	name_of_x <- 	gsub('"',"",deparse(substitute(x)))
	if (!require(name_of_x,character.only=TRUE)){
		install.packages(pkgs=name_of_x,...)
		require(name_of_x,character.only=TRUE)
	}
}

Try the Jmisc package in your browser

Any scripts or data that you put into this service are public.

Jmisc documentation built on June 22, 2022, 9:09 a.m.