Comments (2)
The current approach for using count_patients_with_flags
relies on a step with insert_rrow
to add a title row in a layout. The function should be refactored to include it's own title row. Rationale:
(1) Use of insert_rrow
creates a problem with the indentation - e.g. "Serious AE" row has extra indentation (this is not a bug in rtables
. More background here: insightsengineering/rtables#202)
(2) insert_rrow
may be deprecated (insightsengineering/rtables#214)
Sample code:
library(tern)
library(dplyr)
library(scda)
adsl <- synthetic_cdisc_data("latest")$adsl
adae <- synthetic_cdisc_data("latest")$adae
# Create custom flags:
adae <- adae %>%
mutate(
SER = AESER == "Y",
REL = AEREL == "Y",
CTC35 = AETOXGR %in% c("3", "4", "5"),
CTC45 = AETOXGR %in% c("4", "5")
) %>%
var_relabel(
SER = "Serious AE",
REL = "Related AE",
CTC35 = "Grade 3-5 AE",
CTC45 = "Grade 4/5 AE"
)
aesi_vars <- c("SER", "REL", "CTC35", "CTC45")
# Create layout
lyt <- basic_table() %>%
split_cols_by("ACTARM") %>%
add_colcounts() %>%
count_patients_with_event(
vars = "USUBJID",
filters = c("STUDYID" = as.character(unique(adae$STUDYID))),
denom = "N_col",
.labels = c(count_fraction = "Total number of patients with at least one adverse event")
) %>%
count_patients_with_flags(
"USUBJID",
flag_variables = var_labels(adae[, aesi_vars]),
.indent_mods = 1L
)
result <- build_table(lyt, df = adae, alt_counts_df = adsl)
result <- insert_rrow(result, rrow("Total number of patients with at least one"), at = 2)
result
A: Drug X B: Placebo C: Combination
(N=134) (N=134) (N=132)
-----------------------------------------------------------------------------------------------------
Total number of patients with at least one adverse event 122 (91%) 123 (91.8%) 120 (90.9%)
Total number of patients with at least one
Serious AE 104 (77.6%) 101 (75.4%) 99 (75%)
Related AE 105 (78.4%) 108 (80.6%) 109 (82.6%)
Grade 3-5 AE 109 (81.3%) 104 (77.6%) 109 (82.6%)
Grade 4/5 AE 91 (67.9%) 90 (67.2%) 93 (70.5%)
from tern.
I'm moving this to SME sprint 28 board.
from tern.
Related Issues (20)
- [Feature Request]: Add facet + cohort legend strata order in mean plot HOT 7
- Accept `NULL` in `get_labels_from_stats`
- [Failed to install tern package]: <Failed to install tern package in 4.1.2 R version.> HOT 3
- Revert deprecation of some grob functions until `citril` decorators are refactored
- Minor documentation clean up
- Color by group in individual_patient_plot
- Requirements from checks
- [Bug]: Counting Error in `count_occurrences_by_grade` HOT 2
- [Bug]: "label_all" dose not work in `tabulate_survival_subgroups()` HOT 2
- Manually specify shapes within `g_lineplot` when >6 group levels exist
- [Feature Request]: control line type in g_lineplot
- [Bug]: line disappears in g_lineplot when only one datapoint per timepoint is present
- [Feature Request]: control page numbering style for plots
- Fix indentation in functions using `matrix_form`
- `max_width` of `decorate_grob()` seems to be incorrectly handled HOT 3
- [Bug]: Special characters with emmeans::contrast produce empty output HOT 3
- Add `xticks`, `xlim`, and `ylim` arguments to `g_lineplot`
- [Feature Request]: Add stat_propdiff_ci to tabulate binary response by subgroup
- Integrate better wrapping functions for `decorate_grob` titles and subtitles
- export `tern:::as_factor_keep_attributes`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tern.