-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept clc and hbpc input files individually. Remove brittle input directory API.
- Loading branch information
Showing
6 changed files
with
69 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,58 @@ | ||
#' @title Main | ||
#' @description Build all reports for input data in input directory | ||
#' @note This is the entry point for the application. | ||
#' @param input_dir path to directory that contains clc.csv or hbpc.csv | ||
#' @param ... paths to input files for clc, hbpc, or dementia reports | ||
#' @param config_path path to configuration file | ||
#' @param output_dir path to output directory. Defaults to input_dir | ||
#' @return boolean TRUE indicates successful run. | ||
#' @export | ||
#' | ||
main <- function(input_dir, config_path, output_dir = NULL){ | ||
main <- function(config_path, output_dir = NULL, ...){ | ||
cat("\nDEBUG\n") | ||
cat(config_path) | ||
cat("\nDEBUG\n") | ||
cat(output_dir) | ||
cat("\n") | ||
|
||
input_args <- list(...) | ||
|
||
# Ignore warnings | ||
options(warn = -1) | ||
|
||
# Default to using same directory for input and output | ||
if(is.null(output_dir)){ output_dir <- input_dir } | ||
# Default to using working directory output | ||
if(is.null(output_dir)){ output_dir <- getwd() } | ||
|
||
config <- read_config(config_path) | ||
|
||
# Read in CLC and HBPC data frames | ||
# Read in data | ||
cat("\n\n--- ReadingData\n") | ||
clc_filename <- file.path(input_dir,"clc.csv") | ||
hbpc_filename <- file.path(input_dir,"hbpc.csv") | ||
clc_inpath <- input_args[['clc']] | ||
if(!is.null(clc_inpath) || clc_inpath != ''){ | ||
df_clc <- read_clc_data(input_args[['clc']]) | ||
} | ||
|
||
df_hbpc <- read_hbpc_data(hbpc_filename) | ||
df_clc <- read_clc_data(clc_filename) | ||
hbpc_inpath <- input_args[['hbpc']] | ||
if(!is.null(hbpc_inpath) || hbpc_inpath != ''){ | ||
df_hbpc <- read_hbpc_data(hbpc_inpath) | ||
} | ||
|
||
# Process Data | ||
# Process data | ||
if(!is.null(df_hbpc)){ | ||
hbpc_df_list <- process_data(df_hbpc, envir=GOCC$HBPC) | ||
report_all(hbpc_df_list, GOCC$HBPC, config, output_dir) | ||
}else{ | ||
cat(paste("\nHBPC input file", hbpc_filename, "not present or malformed.\n")) | ||
cat(paste("\nHBPC input file", hbpc_inpath, "not present or malformed.\n")) | ||
hbpc_df_list <- list() | ||
} | ||
|
||
if(!is.null(df_clc)){ | ||
clc_df_list <- process_data(df_clc, envir=GOCC$CLC) | ||
report_all(clc_df_list, GOCC$CLC, config, output_dir) | ||
}else{ | ||
cat(paste("\nCLC input file", clc_filename, "not present or malformed.\n")) | ||
cat(paste("\nCLC input file", clc_inpath, "not present or malformed.\n")) | ||
clc_df_list <- list() | ||
} | ||
|
||
report_all(hbpc_df_list, GOCC$HBPC, config, output_dir) | ||
report_all(clc_df_list, GOCC$CLC, config, output_dir) | ||
|
||
cat("\n\nEnd of Line\n\n") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.