R/setup_pipeline_study.R

#' Set up an analysis pipeline
#'
#' Set up a properly formatted json file describing a study
#'
#' @param name The name of the study
#' @param hypotheses A list of hypotheses in list format (as described in the vignette)
#' @param methods A list of methods in list format (as described in the vignette)
#' @param data A vector of data tables or paths to data files
#' @param analyses A list of analyses in list format (as described in the vignette)
#' @return A list of study parameters (class pipeline_study)
#'
#' @export
#'

setup_pipeline_study <- function(name = "Study",
                        hypotheses = list(),
                        methods = list(),
                        data = list(),
                        analyses = list()) {

  # add checks for each section

  # add ability to load data codebooks from external files
  dataname <- "Data"
  if (is.character(data)) {
    dataname <- data
    data <- rio::import(dataname)
  }
  if (is.data.frame(data)) {
    data <- list(list(name = dataname, data = data))
  }
  if (!is.list(data)) {
    warning("Something is wrong with the data format")
    data <- list()
  }

  study <- list(
    name = name,
    hypotheses = hypotheses,
    methods = methods,
    data = data,
    analyses = analyses
  )

  class(study) <- c(class(study), "pipeline_study")

  invisible(study)
}
debruine/pipeline documentation built on May 8, 2019, 8:59 a.m.