Skip to content

Commit

Permalink
moved chunk of as_epiparam to new function due to cyclocomp
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed May 15, 2023
1 parent 5ba04b3 commit 6e4b25c
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions R/epiparam_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,29 @@ as_epiparam <- function(x) {
)

# create lists for epiparam vector columns
eparam <- add_ci_limits(eparam = eparam, x = x)

# make data an epiparam object
class(eparam) <- c("epiparam", "data.frame")

# validate new epiparam object
validate_epiparam(eparam)

# return epiparam object
eparam
}

#' Adds confidence interval limits from an `epidist` object to an `epiparam`
#' data frame
#'
#' @param eparam A data frame with `<epiparam>` data
#' @param x An `<epidist>` object
#'
#' @return A data frame containing `<epiparam>` data
#' @keywords internal
#' @noRd
add_ci_limits <- function(eparam, x) {

if (is.null(x$uncertainty[["shape"]])) {
eparam$shape_ci_limits <- I(list(c(NA_real_, NA_real_)))
} else {
Expand Down Expand Up @@ -418,13 +441,7 @@ as_epiparam <- function(x) {
eparam$precision_ci_limits <- list(x$uncertainty$precision$ci)
}

# make data an epiparam object
class(eparam) <- c("epiparam", "data.frame")

# validate new epiparam object
validate_epiparam(eparam)

# return epiparam object
# return epiparam
eparam
}

Expand Down

0 comments on commit 6e4b25c

Please sign in to comment.