Skip to content

Commit

Permalink
more examples in ae_table_grade()
Browse files Browse the repository at this point in the history
fixes #32
  • Loading branch information
DanChaltiel committed Jan 20, 2025
1 parent b58ec2e commit 54c74f4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
21 changes: 17 additions & 4 deletions R/ae_table_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,26 @@
#' ae_table_grade(df_ae=ae, df_enrol=enrolres, arm=NULL) %>%
#' as_flextable(header_show_n=TRUE)
#'
#' ae_table_grade(df_ae=ae, df_enrol=enrolres, arm="ARM") %>%
#' ae_table_grade(df_ae=ae, df_enrol=enrolres, arm="arm") %>%
#' as_flextable(header_show_n=TRUE)
#'
#' #To get SAE only, filter df_ae first
#' ae %>%
#' dplyr::filter(sae=="Yes") %>%
#' ae_table_grade(df_enrol=enrolres, arm="ARM", ae_label="SAE") %>%
#' ae_table_grade(df_enrol=enrolres, arm="arm", ae_label="SAE") %>%
#' as_flextable(header_show_n=TRUE)
#'
#' #To describe a sub-population, filter df_enrol first
#' enrolres2 = enrolres %>%
#' dplyr::filter(arm=="Control")
#' ae %>%
#' ae_table_grade(df_enrol=enrolres2, arm="arm") %>%
#' as_flextable(header_show_n=TRUE)
#'
#' #You can also filter the AE table
#' ae %>%
#' ae_table_grade(df_enrol=enrolres, arm="arm") %>%
#' dplyr::filter(!variable %in% c("Grade 1", "Grade 2")) %>%
#' as_flextable(header_show_n=TRUE)
ae_table_grade = function(
df_ae, ..., df_enrol,
Expand Down Expand Up @@ -70,7 +83,7 @@ ae_table_grade = function(
left_join(df_ae, by="subjid") %>%
arrange(subjid) %>%
mutate(
grade = fix_grade(grade),
grade = .fix_grade_na(grade),
)

variant = case_match(variant, "max"~"max_grade", "sup"~"any_grade_sup",
Expand Down Expand Up @@ -318,6 +331,6 @@ ae_plot_grade_n = ae_plot_grade_sum
# Utils ---------------------------------------------------------------------------------------

#' @importFrom dplyr na_if
fix_grade = function(x){
.fix_grade_na = function(x){
as.numeric(na_if(as.character(x), "NA"))
}
17 changes: 15 additions & 2 deletions man/ae_table_grade.Rd

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

0 comments on commit 54c74f4

Please sign in to comment.