R/output_hypotheses.R

#' Output hypotheses
#'
#' Output hypotheses specified in the json file
#'
#' @param study A study list object created with pipeline()
#' @return The study object

output_hypotheses <- function(study) {
  cat("## Hypotheses\n\n")

  for (i in 1:length(study$hypotheses)) {

    cat("### Hypothesis ", i, "\n\n", study$hypotheses[[i]]$desc, "\n\n", sep = "")

    criteria <- study$hypotheses[[i]]$criteria

    for (j in 1:length(criteria)) {
      cat("* Criterion", j, "is confirmed if analysis",
          criteria[[j]]$test, "yields",
          criteria[[j]]$result,
          criteria[[j]]$direction,
          criteria[[j]]$comparator,
          "  \n"
      )
    }

    cat("\n")

    # explain evaluation
    eval <- study$hypotheses[[i]]$evaluation
    if (eval %in% c("&", "and")) {
      cat("If all criteria are met, this hypothesis is supported.")
    } else if (eval %in% c("|", "or")) {
      cat("If any criteria are met, this hypothesis is supported.")
    } else {
      cat(eval)
    }

    cat("\n\n\n")
  }

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