]> nmode's Git Repositories - Rnaught/commitdiff
Change SI units to "day(s)" and "week(s)" in the estimates table
authorNaeem Model <me@nmode.ca>
Sat, 16 Nov 2024 11:18:14 +0000 (11:18 +0000)
committerNaeem Model <me@nmode.ca>
Sat, 16 Nov 2024 11:18:14 +0000 (11:18 +0000)
inst/app/scripts/estimators.R

index a86b1d4aa16a576d39cb3208192be1b738283582..7c457ea41fbde566ce7e2582ecfc8f019a3042ae 100644 (file)
@@ -225,8 +225,9 @@ eval_estimator <- function(estimator, dataset) {
             max_shape = estimator$max_shape, max_scale = estimator$max_scale
           )
           estimated_mu <- round(sum(estimate$supp * estimate$pmf), 2)
             max_shape = estimator$max_shape, max_scale = estimator$max_scale
           )
           estimated_mu <- round(sum(estimate$supp * estimate$pmf), 2)
-          estimate <- paste0(round(estimate$r0, 2), " (SI = ", estimated_mu,
-            " ", tolower(dataset[, 2]), ")"
+          mu_units <- if (dataset[, 2] == "Days") "day(s)" else "week(s)"
+          estimate <- paste0(
+            round(estimate$r0, 2), " (SI = ", estimated_mu, " ", mu_units, ")"
           )
         } else {
           mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
           )
         } else {
           mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
@@ -273,7 +274,8 @@ estimator_mu_text <- function(estimator) {
   if (is.na(estimator$mu)) {
     return("—")
   }
   if (is.na(estimator$mu)) {
     return("—")
   }
-  paste(estimator$mu, tolower(estimator$mu_units))
+  mu_units <- if (estimator$mu_units == "Days") "day(s)" else "week(s)"
+  paste(estimator$mu, mu_units)
 }
 
 # Render the estimates table whenever it is updated.
 }
 
 # Render the estimates table whenever it is updated.