Skip to content

Commit

Permalink
add function extend_ae_summary_eaer
Browse files Browse the repository at this point in the history
  • Loading branch information
wangben718 committed Nov 9, 2023
1 parent 6389fdf commit 9eb1e54
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 14 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
export(extend_ae_specific_duration)
export(extend_ae_specific_events)
export(extend_ae_specific_inference)
export(extend_ae_specific_subgroup)
export(extend_ae_summary_eaer)
export(fmt_ci)
export(fmt_est)
export(fmt_pct)
Expand Down
57 changes: 43 additions & 14 deletions R/extend_ae_summary_eaer.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
# Copyright (c) 2023 Merck & Co., Inc., Rahway, NJ, USA and its affiliates.
# All rights reserved.
#
# This file is part of the metalite.ae program.
#
# metalite.ae is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#' Add exposure-adjusted rate information for AE summary analysis
#'
#' @param outdata An `outdata` object created by [prepare_ae_summary()].
#' @param duration_var A character value of duration variable name.
#' By default, `"TRTDUR"` is used.
#' @param adj_unit A character value of exposure adjusted unit.
#' It could be select from `"year"`, `"month"`, `"week"`, and `"day"`.
#'
#' @return A list of analysis raw datasets.
#'
#' @export
#'
#' @examples
#' meta <- meta_ae_example()
#' prepare_ae_summary(
#' meta,
#' population = "apat",
#' observation = "wk12",
#' parameter = "any;rel;ser"
#' ) |>
#' extend_ae_summary_eaer()
extend_ae_summary_eaer <- function(outdata,
duration_var = "TRTDUR",
adj_unit = c("year", "month", "week", "day"),
...) {
adj_unit = c("year", "month", "week", "day")) {
time_unit <- list("year" = 365.24, "month" = 30.4367, "week" = 7, "day" = 1)
adj_unit <- match.arg(adj_unit)
exp_factor <- 100 * time_unit[[adj_unit]]
Expand All @@ -25,19 +63,10 @@ extend_ae_summary_eaer <- function(outdata,
})

adj_rate_table <- do.call(rbind, res)
outdata$total_exp <- total_exposure
outdata$eaer <- adj_rate_table

metalite::outdata(meta, population, observation, parameter,
n = rbind(n_pop, tbl_num),
order = c(1, seq_len(nrow(tbl_num)) * 100),
group = res[[1]]$group,
reference_group = res[[1]]$reference_group,
prop = rbind(pop_prop, tbl_prop),
diff = rbind(pop_diff, tbl_diff),
n_pop = n_pop,
name = c(pop_name, name),
prepare_call = match.call(),
eaer = eaer
)
outdata
}


Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ reference:
- prepare_ae_summary
- format_ae_summary
- tlf_ae_summary
- extend_ae_summary_eaer
- title: AE specification
contents:
- prepare_ae_specific
Expand Down
37 changes: 37 additions & 0 deletions man/extend_ae_summary_eaer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9eb1e54

Please sign in to comment.