#' Setup jch misc
#'
#' Install DEBS and packages.
#' @export
setup_jch = function() {
install_debs()
install_packages()
}
#' Install packages
#'
#' Install multiple packages (unless already installed).
#' @export
install_packages = function() {
data(pkgs)
for (pkg in pkgs) {
message(pkg)
if (!require(pkg, character.only = TRUE))
tryCatch(
expr = install.packages(pkg),
error = function(e) e$message
)
}
}
#' Install debs
#'
#' Install deb libraries
#' @export
install_debs = function() {
data(debs)
gksudor("apt-get install", debs, run = TRUE)
}
#' Use graphical sudo
#'
#' Call a command using gksudo
#' @param command Command to call (such as \code{"apt-get install"})
#' @param args Arguments
#' @param run Whether to also call the command (defaults to \code{TRUE})
#' @export
gksudor = function(command, args, run = TRUE) {
command = paste(
"gksudo",
command, paste(args, collapse = " "),
collapse = " ")
if (run)
system(command)
else
commmand
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.