R/read_estimates_from_xl.R

Defines functions read_estimates_from_xl

Documented in read_estimates_from_xl

#' Load estimates from an Excel file
#'
#' This function loads estimates that have been exported
#' from an Excel file. For loading estimates from
#' completed performance tables, use [mdmcda::read_performance_tables()].
#'
#' @param file The filename.
#' @param multiEstimateDf Whether the file contains an exported
#' `multiEstimateDf`.
#'
#' @return The object with the estimates, containing the spreadsheet in
#' `$multiEstimateDf`.
#'
#' @export
read_estimates_from_xl <- function(file,
                                   multiEstimateDf = TRUE) {

  dat <- openxlsx::read.xlsx(file);

  res <- list(
    performance_subtables = NULL,
    confidences = NULL,
    estimateCoders = NULL,
    estimatorCodeVector = NULL,
    estimatorCodes = NULL,
    estimates = NULL,
    multiEstimateLegend = NULL,
    multiEstimateInverseLegend = NULL,
    multiEstimateDf = NULL,
    mergedConfidences = NULL,
    processedConfidences = NULL,
    alternativeValues = NULL,
    collapsedConfidences = NULL,
    confidencesByDecisionPlot = NULL,
    confidencesByCriterionPlot = NULL,
    confidencesInDetail = NULL,
    originalAlternativeValues = NULL
  );

  if (multiEstimateDf) {

    res$multiEstimateDf <- dat;

  } else {
    stop("No other importing functionality added yet, sorry!");
  }

  return(res);

}
Matherion/mdmcda documentation built on Dec. 31, 2020, 3:13 p.m.