#' `load and install CRAN packages`
#'
#' @param packages list of packages to install from CRAN
#'
#' @export
#'
#' @return packages loaded into environment
`load and install CRAN packages` <- function(packages) {
`installed packages` <- rownames(installed.packages())
`to be installed` <- packages[ !( packages %in% `installed packages` ) ]
##-- install from CRAN --##
if ( length(`to be installed`) > 0 ) {
install.packages(`to be installed`,
repos = "http://cran.us.r-project.org")
}
##-- load all packages --##
sapply(packages,
require,
character.only = TRUE)
}
#' `load and install Bioconductor packages`
#'
#' @param packages list of packages to install from Bioconductor
#'
#' @export
#'
#' @return packages loaded into environment
`load and install Bioconductor packages` <- function(packages) {
`installed packages` <- rownames(installed.packages())
`to be installed` <- packages[ !( packages %in% `installed packages` ) ]
##-- install from CRAN --##
if ( length(`to be installed`) > 0 ) {
source("https://bioconductor.org/biocLite.R")
biocLite(`to be installed`, ask = FALSE)
}
##-- load all packages --##
sapply(packages,
require,
character.only = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.