From ced3151c0efe35a2c41b766be6d42badf00e3730 Mon Sep 17 00:00:00 2001 From: mrustl Date: Thu, 27 Jun 2024 14:47:25 +0200 Subject: [PATCH] Adapt to be used for multi-solute definition --- R/prepare_atmosphere_input.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/prepare_atmosphere_input.R b/R/prepare_atmosphere_input.R index 6e936cc..897562c 100644 --- a/R/prepare_atmosphere_input.R +++ b/R/prepare_atmosphere_input.R @@ -31,8 +31,15 @@ prepare_atmosphere_input <- function( ) { required_parameters <- get_atmosphere_headers() + n_solutes_per_run <- 12 + optional_parameters <- sapply(2:n_solutes_per_run, function(i) { + c(sprintf("cTop%d", i), sprintf("cBot%d", i)) + }) %>% as.vector() + + is_given <- required_parameters %in% names(inputs) + is_given_optional <- optional_parameters %in% names(inputs) has_default <- required_parameters %in% names(defaults) if (any(is_missing <- !is_given & !has_default)) { @@ -44,7 +51,9 @@ prepare_atmosphere_input <- function( dplyr::bind_cols( inputs[, required_parameters[is_given], drop = FALSE], + inputs[, optional_parameters[is_given_optional], drop = FALSE], defaults[, required_parameters[!is_given & has_default], drop = FALSE] ) %>% - dplyr::select(tidyselect::all_of(required_parameters)) + dplyr::select(tidyselect::all_of(required_parameters), + tidyselect::all_of(optional_parameters[is_given_optional])) }