From a31003bcee5687680a32d3adcc2163745724f17c Mon Sep 17 00:00:00 2001 From: Tony Gardella Date: Wed, 23 Oct 2024 10:17:11 -0400 Subject: [PATCH 1/2] update converTemps to handle variation in case of from arg --- FrEDI/R/convertTemps.R | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/FrEDI/R/convertTemps.R b/FrEDI/R/convertTemps.R index 985aab52..b92f8ecd 100644 --- a/FrEDI/R/convertTemps.R +++ b/FrEDI/R/convertTemps.R @@ -33,13 +33,18 @@ convertTemps <- function( c0 <- 0 ### Update c1 <- 1.421 ### Update - toType <- from |> tolower() - if(from == "global"){ + ## Make "from" argument lowercase + fromType <- from |> tolower() + + if(fromType == "global"){ temp_global <- temps new_temps <- c1*temp_global + c0 - } else{ + } else if(fromType == "conus"){ temp_conus <- temps new_temps <- (temp_conus - c0)/c1 + } else { + print("Please enter Conus or Global in `from` argument") + return() } ###### Return ###### From 0696172c5c2df03f46d08bf67828f54718f84118 Mon Sep 17 00:00:00 2001 From: Tony Gardella Date: Wed, 23 Oct 2024 14:27:35 -0400 Subject: [PATCH 2/2] update converTemps error handling --- FrEDI/R/convertTemps.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/FrEDI/R/convertTemps.R b/FrEDI/R/convertTemps.R index b92f8ecd..df3277d9 100644 --- a/FrEDI/R/convertTemps.R +++ b/FrEDI/R/convertTemps.R @@ -43,8 +43,7 @@ convertTemps <- function( temp_conus <- temps new_temps <- (temp_conus - c0)/c1 } else { - print("Please enter Conus or Global in `from` argument") - return() + stop("Warning! In convertTemps(): Invalid value provided to from argument. Please enter a valid value. Exiting...") } ###### Return ######