#' setpwd
#'
#' set current working directory to the RScript path
#' setpwd ensure when the script is envoke by RScript,
#' the working directory should be where the script locates
#'
#' set pwd for Rscript
#' @return current_pwd
#' @export
setpwd <- function() {
pwd <- getwd()
if (!interactive()) {
CArgs <- commandArgs(trailingOnly=FALSE)
setwd(dirname(sub("^--file=", "", CArgs[grepl("^--file=", CArgs)])))
}
invisible(pwd)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.