R/read_analysis_results.R

Defines functions read_analysis_results

Documented in read_analysis_results

#' Reads all the the results from a directory, with path is specified in
#' `data_folder_path`.
#'
#' @inheritParams default_params_doc
#'
#' @return A list of results
#' @export
#'
#' @examples
#' \dontrun{
#' results <- DAISIEmainland::read_analysis_results(
#'   file.path("tests", "testthat", "testdata")
#' )
#' }
read_analysis_results <- function(data_folder_path) {
  # load all the files from the path
  files <- list.files(data_folder_path)
  if (length(files) == 0) {
    stop("No results are in the results directory")
  } else {
    file_paths <- as.list(paste0(data_folder_path, "/", files))
    analysis_results_list <- lapply(file_paths, readRDS)
  }
  # check whether the files loaded are the correct format
  lapply(analysis_results_list, check_analysis_result)
  analysis_results_list
}
joshwlambert/DAISIEmainland documentation built on July 14, 2024, 5:40 p.m.