#' Output results
#'
#' Output results specified in the json file
#'
#' @param study A study list object created with pipeline()
#' @param digits integer indicating the number of decimal places.
#' @return The study object
output_results <- function(study, digits = 3) {
cat("## Results\n\n")
for (i in 1:length(study$hypotheses)) {
cat("### Hypothesis ", i, "\n\n", study$hypotheses[[1]]$desc, "\n\n", sep = "")
criteria <- study$hypotheses[[i]]$criteria
for (j in 1:length(criteria)) {
analysis <- grep(criteria[[j]]$analysis, study$analyses, fixed = TRUE)
result <- study$analyses[[analysis]]$results[[criteria[[j]]$result]]
cat("* Criterion ", j, " was ",
criteria[[j]]$result, " ",
criteria[[j]]$direction, " ",
criteria[[j]]$comparator,
" in analysis ", criteria[[j]]$analysis, ". \n The result was ",
criteria[[j]]$result, " = ", round_char(result, digits),
" \n",
sep = ""
)
}
cat("\n**Conclusion**: ")
eval <- study$hypotheses[[i]]$evaluation
conclusion <- study$hypotheses[[i]]$conclusion
if (eval %in% c("&", "and")) {
if (conclusion) {
cat("Congratulations! All criteria were met, this hypothesis was supported.")
} else {
cat("All criteria were not met, this hypothesis was not supported.")
}
} else if (eval %in% c("|", "or")) {
if (conclusion) {
cat("At least one criterion was met, this hypothesis was supported.")
} else {
cat("No criteria were met, this hypothesis was not supported.")
}
} else {
cat("The evaluation criteria could not be automatically evaluated.")
}
cat("\n\n")
}
invisible(study)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.