install <- function(pkg = NULL) {
pkg_dir <- paste0(getwd(), "/r_packages")
while (!dir.exists("r_packages")) {
# Create r_packages dir
if (!dir.exists((pkg_dir))) {
dir.create(pkg_dir)
}
}
install.packages(pkg, lib = pkg_dir)
packages <- yaml::read_yaml(file = "./packages.yaml")
dep <- list()
dep[[pkg]] <- toString(packageVersion(pkg, lib.loc = pkg_dir))
if (is.null(packages$depencies)) {
packages$depenencies <- c(dep)
} else {
append(packages$depenencies, dep)
}
yaml::write_yaml(file = "./packages.yaml", packages)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.