R/save_pipeline.R

#' Save a study list as a JSON file
#'
#' Save a study list as a JSON file
#'
#' @param study A study list object created with pipeline()
#' @param filename The file path to save to
#' @return Saves study as a JSON file with the specified name
#'
#' @export
#'
save_pipeline <- function(study, filename = "study.json") {
  if (!grep("\\.json$", filename)) {
    # add .json extension if not already specified
    filename <- paste0(filename, ".json")
  }

  study %>%
    jsonlite::toJSON(auto_unbox = TRUE) %>%
    jsonlite::prettify(indent = 2) %>%
    writeLines(filename)
}
debruine/pipeline documentation built on May 8, 2019, 8:59 a.m.