From bd5cec3b27a2f890770096764b5f2baf74663be3 Mon Sep 17 00:00:00 2001 From: Sebastian Funk Date: Wed, 22 Nov 2023 15:22:01 +0000 Subject: [PATCH] linting --- R/adjust.R | 8 +++----- R/dist.R | 6 +++--- R/get.R | 2 +- R/report.R | 2 +- R/utilities.R | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/R/adjust.R b/R/adjust.R index d22b05a8b..5ff7d6ed1 100644 --- a/R/adjust.R +++ b/R/adjust.R @@ -148,12 +148,10 @@ adjust_infection_to_report <- function(infections, delay_defs, deprecate_warn( "2.0.0", "adjust_infection_to_report(delay_defs = 'should be a dist_spec')", - details = c( - "Specifying this as a list of data tables is deprecated." - ) + details = "Specifying this as a list of data tables is deprecated." ) report <- sample_single_dist(infections, delay_defs[[1]]) - if (length(delay_defs ) > 1) { + if (length(delay_defs) > 1) { for (def in 2:length(delay_defs)) { report <- sample_single_dist(report, delay_defs[[def]]) } @@ -181,7 +179,7 @@ adjust_infection_to_report <- function(infections, delay_defs, } ## Truncate reported cases by maximum infection date - if (type %in% "sample" && truncate_future) { + if (type == "sample" && truncate_future) { report <- report[date <= max(infections$date)] } return(report) diff --git a/R/dist.R b/R/dist.R index 1b05b956e..cfca88dd1 100644 --- a/R/dist.R +++ b/R/dist.R @@ -127,7 +127,7 @@ dist_skel <- function(n, dist = FALSE, cum = TRUE, model, plnorm(n, params[["meanlog"]], params[["sdlog"]])) / plnorm(max_value + 1, params[["meanlog"]], params[["sdlog"]]) } - } else if (model %in% "normal") { + } else if (model == "normal") { rdist <- function(n) { rnorm(n, params[["mean"]], params[["sd"]]) } @@ -903,7 +903,7 @@ dist_spec <- function(distribution = c( "dist_spec(fixed)", "fix_dist()" ) - params_sd <- c() + params_sd <- NULL } ## check for deprecated parameters if (!all(missing(mean), missing(sd), missing(mean_sd), missing(sd_sd)) && @@ -941,7 +941,7 @@ dist_spec <- function(distribution = c( params_sd <- c(mean = mean_sd, sd = sd_sd) } else if (distribution == "fixed") { params_mean <- mean - params_sd <- c() + params_sd <- NULL } } return(.dist_spec(distribution, params_mean, params_sd, max, pmf)) diff --git a/R/get.R b/R/get.R index f05161dc7..b3a284734 100644 --- a/R/get.R +++ b/R/get.R @@ -16,7 +16,7 @@ get_regions <- function(results_dir) { ) # put into alphabetical order - regions <- regions[!(regions %in% "runtimes.csv")] + regions <- regions[!(regions == "runtimes.csv")] regions <- sort(regions) names(regions) <- regions return(regions) diff --git a/R/report.R b/R/report.R index 21ae87af0..a055118b1 100644 --- a/R/report.R +++ b/R/report.R @@ -201,7 +201,7 @@ report_summary <- function(summarised_estimates, } if (!is.null(target_folder)) { - saveRDS(summary, paste0(target_folder, "/summary.rds")) + saveRDS(summary, file.path(target_folder, "summary.rds")) } return(summary) } diff --git a/R/utilities.R b/R/utilities.R index a095e62ef..e15c65bf7 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -62,8 +62,8 @@ make_conf <- function(value, CrI = 90, reverse = FALSE) { ) conf <- paste0( value$median, " (", - ifelse(!reverse, CrI$lower, CrI$upper), " -- ", - ifelse(!reverse, CrI$upper, CrI$lower), ")" + ifelse(reverse, CrI$upper, CrI$lower), " -- ", + ifelse(reverse, CrI$lower, CrI$upper), ")" ) return(conf) }