#' Empirical Best Prediction of poverty indicators
#'
#' Function \code{getPackages}
#' @param
#' @return bla
#'
#' @details longbla
#' @export
getPackages <- function(pList){
status <- sapply(pList, getPackage)
if( any( status == "failed" )) {
warnString <- paste("The packages ", names(status)[status=="failed"]," could not be loaded", collapse = ", ")
warning(warnString)
}
return(status)
}
getPackage <- function(name) {
if (!as.logical(require(name, character.only = TRUE, quietly = T))) {
try(install.packages(name))
require(name, character.only = TRUE)
}
if (isinSearchpath(name)) {
return("successfull")
} else {
return("failed")
}
}
isinSearchpath <- function(name) {
return(length(grep(paste0("^package:", name, "$"), search())) >
0)
}
#pkgsNeeded = c("nlme", "ggplot2", "gridExtra", "maptools", "xlsx",
# "ggmap", "actuar", "parallel", "laeken", "copula")
#sapply(pkgsNeeded, getPackage)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.