#' Build package manually
#'
#' @description
#' This function was specifically designed to build a package from local source
#' files manually, i.e., without using the package building functionality
#' offered e.g. by RStudio.
#'
#' @param dsn 'character'. Target folder containing source files; defaults to
#' the current working directory.
#' @param document 'logical'. Determines whether or not to invoke
#' \code{\link{roxygenize}} with default roclets.
#' @param ... Further arguments passed on to \code{\link[devtools]{build}}.
#'
#' @seealso
#' \code{\link{roxygenize}}, \code{\link[devtools]{build}},\code{\link{install.packages}}.
#'
#' @author
#' Florian Detsch
#'
#' @examples
#' \dontrun{
#' ## when in a package directory, e.g. '~/satellite'
#' manualBuild()
#' }
#'
#' @export manualBuild
#' @name manualBuild
manualBuild <- function(dsn = getwd(), document = TRUE, ...) {
## reset 'dsn' to 'H:/...'
if (length(grep("students_smb", dsn)) > 0) {
lst_dsn <- strsplit(dsn, "/")
chr_dsn <- unlist(lst_dsn)[3:5]
dsn <- paste0("H:/", paste(chr_dsn, collapse = "/"))
}
## if 'document = TRUE', create documentation
if (document) {
cat("\nCreating package documentation...\n")
roxygen2::roxygenize(package.dir = dsn,
roclets = c('rd', 'collate', 'namespace'))
}
## build package
cat("\nBuilding package...\n")
devtools::build(pkg = dsn, path = dirname(dsn), ...)
## install package
cat("Installing package...\n")
pkg <- list.files(dirname(dsn), full.names = TRUE,
pattern = paste0(basename(dsn), ".*.tar.gz$"))
pkg <- pkg[length(pkg)]
install.packages(pkg, repos = NULL)
return(invisible(NULL))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.