diff --git a/R/create-Rmd-table.R b/R/create-Rmd-table.R index 09fdcb0..a5bdfe8 100644 --- a/R/create-Rmd-table.R +++ b/R/create-Rmd-table.R @@ -1,5 +1,5 @@ create_Rmd_table <- function(file_type, file_metadata, column_metadata, column_category_metadata) { - column_metadata_rows <- column_metadata[column_metadata$fileName == file_type, ] + column_metadata_rows <- column_metadata[.matches_file_type(column_metadata$fileName, file_type), ] if(nrow(column_metadata_rows) == 0) { stop(glue::glue("No column metadata rows found for file {file_type}")) } diff --git a/R/create-reference-Rmd.R b/R/create-reference-Rmd.R index 498b709..f8fc205 100644 --- a/R/create-reference-Rmd.R +++ b/R/create-reference-Rmd.R @@ -43,7 +43,7 @@ create_reference_Rmd <- function( ) column_metadata_for_file <- column_metadata[ - column_metadata$fileName == file_name, + .matches_file_type(column_metadata$fileName, file_name), ] if(nrow(column_metadata_for_file) == 0) { stop(paste("No column metadata found for file", file_name)) diff --git a/R/matches-file-type.R b/R/matches-file-type.R new file mode 100644 index 0000000..6c436aa --- /dev/null +++ b/R/matches-file-type.R @@ -0,0 +1,12 @@ +#' Tests the `fileName` column in the column metadata file for the existence of +#' a file +#' +#' @param files_names the fileName column +#' @param file_type the file name to check for +#' +#' @return a logical vector +#' +#' @keywords internal +.matches_file_type <- function(file_names, file_type) { + sapply(strsplit(file_names, ";"), function(names) file_type %in% names) +} diff --git a/R/validate-model-paramater-file.R b/R/validate-model-paramater-file.R index 58c7aef..6d92e51 100644 --- a/R/validate-model-paramater-file.R +++ b/R/validate-model-paramater-file.R @@ -123,12 +123,12 @@ validate_file <- function(file, column_metadata, column_category_metadata) { current_file_metadata <- file_metadata[file_metadata$fileName == file_type,] - + if (nrow(current_file_metadata) == 0) { stop(glue::glue("No rows found in file metadata for file type {file_type}")) } - - file_column_metadata <- column_metadata[column_metadata$fileName == file_type,] + + file_column_metadata <- column_metadata[.matches_file_type(column_metadata$fileName, file_type),] if (nrow(file_column_metadata) == 0) { stop(glue::glue("No rows found in columns metadata for file type {file_type}")) } diff --git a/docs/2-model-parameter-files.qmd b/docs/2-model-parameter-files.qmd index 5f06373..7380067 100644 --- a/docs/2-model-parameter-files.qmd +++ b/docs/2-model-parameter-files.qmd @@ -1,4 +1,5 @@ ```{r echo=FALSE} +source("../R/matches-file-type.R") source("../R/create-Rmd-table.R") ``` diff --git a/docs/5-reference.qmd b/docs/5-reference.qmd index f3b161b..8083020 100644 --- a/docs/5-reference.qmd +++ b/docs/5-reference.qmd @@ -1,4 +1,5 @@ ```{r, echo=FALSE, results='asis'} +source("../R/matches-file-type.R") source("../R/create-reference-Rmd.R") file_metadata <- read.csv( diff --git a/docs/_quarto.yml b/docs/_quarto.yml index 99c3b96..e70e4c8 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -3,6 +3,8 @@ project: output-dir: dist post-render: ./generate_llms_script.R +quarto-required: ">=1.9.0" + website: title: "Model Parameter Files" sidebar: diff --git a/inst/metadata/column-metadata.csv b/inst/metadata/column-metadata.csv index 0752e5a..9e3787e 100644 --- a/inst/metadata/column-metadata.csv +++ b/inst/metadata/column-metadata.csv @@ -54,9 +54,9 @@ validate,value,The value to use when applying the validation,string,FALSE,,,, validate,error_handle,How to handle failed validations,category,FALSE,,,, validate,error_replace,Value to replace variables that fail validations whose errorHandle value is warning,string,FALSE,,,, validate,location,Which step in the scoring process the validation should be used,string,FALSE,,,, -beta-coefficients,variable,The name of the variable whose beta coefficient the row contains. If this is the coefficient for the intercept then use the name "Intercept",string,FALSE,,,, -beta-coefficients,coefficient,The beta coefficient,number,FALSE,,,, -beta-coefficients,type,The statistical type of the variable,category,FALSE,,,, +beta-coefficients;logistic-regression,variable,The name of the variable whose beta coefficient the row contains. If this is the coefficient for the intercept then use the name "Intercept",string,FALSE,,,, +beta-coefficients;logistic-regression,coefficient,The beta coefficient,number,FALSE,,,, +beta-coefficients;logistic-regression,type,The statistical type of the variable,category,FALSE,,,, baseline-hazards,time,The time upto which the baseline hazard should be used,number,FALSE,,,, baseline-hazards,baselineHazard,The baseline hazard value,number,FALSE,,,, survival_bins,catValue,The bin number,number,FALSE,,,, @@ -66,6 +66,3 @@ tables,tableName,The name of the table,string,FALSE,,,, tables,tablePath,The path to the table relative to this file,string,FALSE,,,, simple-model,name,The name of the metadata,category,FALSE,,,, simple-model,value,The value of the metadata,string,FALSE,,,, -logistic-regression,variable,The name of the variable whose beta coefficient the row contains. If this is the coefficient for the intercept then use the name "Intercept",string,FALSE,,,, -logistic-regression,coefficient,The beta coefficient,number,FALSE,,,, -logistic-regression,type,The statistical type of the variable,category,FALSE,,,,