From fb1800c9ec225195623a25de5120bfe5df515902 Mon Sep 17 00:00:00 2001 From: Adam Howes Date: Fri, 10 May 2024 14:57:56 +0100 Subject: [PATCH] Issue 17: Fixes to data.table assignment (#18) * Add omitted assignments * Correct typo (draw to draws) as suggested by seabbs * Add Adam Howes as contributor Former-commit-id: 358d4706f12e5c68058a627f9fa101d8e40eae76 [formerly efd2f7e7a841c31d86106f231ebeab82989de206] Former-commit-id: 59460a126c53f6fa91f66c3f51ec3b405d4069f0 --- DESCRIPTION | 6 +++++- R/fitting-and-postprocessing.R | 2 +- R/observe.R | 2 +- R/plot-helpers.R | 2 +- R/preprocess.R | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7b188c601..22f69d506 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,7 +10,11 @@ Authors@R: person(given = "Sam Abbott", role = c("aut"), email = "contact@samabbott.co.uk", - comment = c(ORCID = "0000-0001-8057-8037"))) + comment = c(ORCID = "0000-0001-8057-8037")), + person(given = "Adam Howes", + role = c("aut"), + email = "adamthowes@gmail.com", + comment = c(ORCID = "0000-0003-2386-4031"))) Description: Understanding and accurately estimating epidemiological delay distributions is important for public health policy. These estimates directly influence epidemic situational awareness, control strategies, and resource allocation. In this package, we provide methods to address the key challenges in estimating these distributions, including truncation, interval censoring, and dynamical biases. Despite their importance, these issues are frequently overlooked, often resulting in biased conclusions. diff --git a/R/fitting-and-postprocessing.R b/R/fitting-and-postprocessing.R index 800c7d04d..be1531bbb 100644 --- a/R/fitting-and-postprocessing.R +++ b/R/fitting-and-postprocessing.R @@ -204,7 +204,7 @@ primary_censoring_bias_correction <- function(draws) { draws <- data.table::copy(draws) draws[, mean := mean - runif(.N, min = 0, max = 1)] draws[, meanlog := log(mean^2 / sqrt(sd^2 + mean^2))] - draw[, sdlog := sqrt(log(1 + (sd^2 / mean^2)))] + draws[, sdlog := sqrt(log(1 + (sd^2 / mean^2)))] return(draws[]) } diff --git a/R/observe.R b/R/observe.R index 28f751f23..7df01e621 100644 --- a/R/observe.R +++ b/R/observe.R @@ -82,7 +82,7 @@ pad_zero <- function(data, pad = 1e-3) { #' @export drop_zero <- function(data) { data <- data.table::copy(data) - data[delay_daily != 0] + data <- data[delay_daily != 0] return(data) } diff --git a/R/plot-helpers.R b/R/plot-helpers.R index 437392aab..3ef5e9022 100644 --- a/R/plot-helpers.R +++ b/R/plot-helpers.R @@ -9,7 +9,7 @@ calculate_cohort_mean <- function(data, type = c("cohort", "cumulative"), mean = mean(delay_daily), n = .N), by = c("ptime_daily", by)] - out[order(rank(ptime_daily))] + out <- out[order(rank(ptime_daily))] if (type == "cumulative") { out[, mean := cumsum(mean * n) / cumsum(n), by = by] diff --git a/R/preprocess.R b/R/preprocess.R index df6c38055..8a21e720d 100644 --- a/R/preprocess.R +++ b/R/preprocess.R @@ -142,7 +142,7 @@ event_to_incidence <- function(data, by = c()) { dd <- data.table::copy(data) dd[, .(cases = .N), by = c("ptime_daily", by)] - dd[order(ptime_daily)] + dd <- dd[order(ptime_daily)] setnames(dd, old = c("ptime_daily"), new = c("time"))