diff --git a/R/simulate.R b/R/simulate.R index 25994a5c2..7ef51b578 100644 --- a/R/simulate.R +++ b/R/simulate.R @@ -116,19 +116,19 @@ simulate_gillespie <- function(r = 0.2, #' distribution. The input dataset should have the primary event times in a #' column named `ptime`. #' -#' @param linelist A data frame with the primary event times. +#' @param data A data frame with the primary event times. #' @param dist The delay distribution to be used. Defaults to [rlnorm()]. #' @param ... Arguments to be passed to the delay distribution function. #' -#' @return A `data.frame` that augments `linelist` with two new columns: `delay` +#' @return A `data.frame` that augments `data` with two new columns: `delay` #' (secondary event latency) and `stime` (the time of the secondary event). #' #' @family simulate #' @autoglobal #' @importFrom dplyr mutate #' @export -simulate_secondary <- function(linelist, dist = rlnorm, ...) { - linelist |> +simulate_secondary <- function(data, dist = rlnorm, ...) { + data |> mutate( delay = dist(dplyr::n(), ...), stime = .data$ptime + .data$delay diff --git a/man/simulate_secondary.Rd b/man/simulate_secondary.Rd index e0e097972..da84f0168 100644 --- a/man/simulate_secondary.Rd +++ b/man/simulate_secondary.Rd @@ -4,17 +4,17 @@ \alias{simulate_secondary} \title{Simulate secondary events based on a delay distribution} \usage{ -simulate_secondary(linelist, dist = rlnorm, ...) +simulate_secondary(data, dist = rlnorm, ...) } \arguments{ -\item{linelist}{A data frame with the primary event times.} +\item{data}{A data frame with the primary event times.} \item{dist}{The delay distribution to be used. Defaults to \code{\link[=rlnorm]{rlnorm()}}.} \item{...}{Arguments to be passed to the delay distribution function.} } \value{ -A \code{data.frame} that augments \code{linelist} with two new columns: \code{delay} +A \code{data.frame} that augments \code{data} with two new columns: \code{delay} (secondary event latency) and \code{stime} (the time of the secondary event). } \description{