Function reference
-
tern
tern-package
- tern Package
-
formatting_functions
- Additional Formatting Functions
-
kaplan_meier
- Kaplan-Meier Plot
Control Functions
These functions capture options in lists and take care of defaults (and checks where applicable). They avoid cluttering of function signatures with long lists of single arguments.
-
control_coxph()
- Control Function for
CoxPH
Model
-
control_coxreg()
- Controls for Cox Regression
-
control_incidence_rate()
- Control function for incidence rate
-
control_lineplot_vars()
- Control Function for g_lineplot Function
-
control_logistic()
- Control Function for Logistic Regression Model Fitting
-
control_step()
- Control Function for Subgroup Treatment Effect Pattern (STEP) Calculations
-
control_summarize_vars()
- Control Function for Descriptive Statistics
-
control_surv_time()
- Control Function for
survfit
Model for Survival Time
-
control_surv_timepoint()
- Control Function for
survfit
Model for Patient's Survival Rate at time point
Analysis Functions
Analyze functions with their corresponding statistics functions and formatted analysis functions.
Statistics functions (denoted by
s_
prefix) compute the numbers that are tabulated later. In order to separate computation from formatting, they do not take care ofrcell
type formatting themselves.Formatted analysis functions (denoted by
a_
prefix) have the same arguments as the corresponding statistics functions, and can be further customized by callingrtables::make_afun()
on them. They are used asafun
inrtables::analyze()
.Analyze functions are used in combination with
rtables
layout functions in the pipeline which creates the table.
-
analyze_vars_in_cols()
- Summary numeric variables in columns
-
s_num_patients()
s_num_patients_content()
summarize_num_patients()
analyze_num_patients()
- Number of patients
-
s_compare()
a_compare()
compare_vars()
- Compare Variables Between Groups
-
s_count_abnormal()
a_count_abnormal()
count_abnormal()
- Patient Counts with Abnormal Range Values
-
s_count_abnormal_by_baseline()
a_count_abnormal_by_baseline()
count_abnormal_by_baseline()
- Patient Counts with Abnormal Range Values by Baseline Status
-
s_count_abnormal_by_marked()
a_count_abnormal_by_marked()
count_abnormal_by_marked()
- Count Patients with Marked Laboratory Abnormalities
-
s_count_abnormal_by_worst_grade()
a_count_abnormal_by_worst_grade()
count_abnormal_by_worst_grade()
- Patient Counts with the Most Extreme Post-baseline Toxicity Grade per Direction of Abnormality
-
s_count_abnormal_lab_worsen_by_baseline()
a_count_abnormal_lab_worsen_by_baseline()
count_abnormal_lab_worsen_by_baseline()
- Patient Counts for Laboratory Events (Worsen From Baseline) by Highest Grade Post-Baseline
-
s_count_cumulative()
a_count_cumulative()
count_cumulative()
- Cumulative Counts with Thresholds
-
s_count_nonmissing()
s_count_missed_doses()
a_count_missed_doses()
count_missed_doses()
- Counting Missed Doses
-
s_count_occurrences()
a_count_occurrences()
count_occurrences()
- Occurrence Counts
-
s_count_occurrences_by_grade()
a_count_occurrences_by_grade()
count_occurrences_by_grade()
summarize_occurrences_by_grade()
- Occurrence Counts by Grade
-
s_count_patients_and_multiple_events()
summarize_patients_events_in_cols()
- Counting Patients and Events in Columns
-
s_count_patients_with_event()
a_count_patients_with_event()
count_patients_with_event()
s_count_patients_with_flags()
a_count_patients_with_flags()
count_patients_with_flags()
- Count the Number of Patients with a Particular Event
-
s_count_values()
a_count_values()
count_values()
- Counting Specific Values
-
s_length_proportion()
a_length_proportion()
estimate_multinomial_response()
- Estimation of Proportions per Level of Factor
-
s_proportion()
a_proportion()
estimate_proportion()
- Estimation of Proportions
-
s_incidence_rate()
a_incidence_rate()
estimate_incidence_rate()
- Incidence Rate
-
s_odds_ratio()
a_odds_ratio()
estimate_odds_ratio()
- Odds Ratio Estimation
-
s_proportion_diff()
a_proportion_diff()
estimate_proportion_diff()
- Proportion Difference
-
s_coxreg()
summarize_coxreg()
- Cox Proportional Hazards Regression
-
s_ancova()
a_ancova()
summarize_ancova()
- Summary for analysis of covariance (ANCOVA).
-
s_change_from_baseline()
a_change_from_baseline()
summarize_change()
- Summarize the Change from Baseline or Absolute Baseline Values
-
summarize_colvars()
- Summarize Variables in Columns
-
s_glm_count()
a_glm_count()
summarize_glm_count()
- Summary for Poisson Negative Binomial.
-
summarize_logistic()
- Multi-Variable Logistic Regression Table
-
s_count_patients_sum_exposure()
summarize_patients_exposure_in_cols()
- Counting Patients Summing Exposure Across All Patients in Columns
-
s_summary()
a_summary()
summarize_vars()
- Summarize Variables
-
s_surv_time()
a_surv_time()
surv_time()
- Survival Time Analysis
-
s_surv_timepoint()
a_surv_timepoint()
s_surv_timepoint_diff()
a_surv_timepoint_diff()
surv_timepoint()
- Survival Time Point Analysis
-
tabulate_rsp_biomarkers()
- Tabulate Biomarker Effects on Binary Response by Subgroup
-
a_response_subgroups()
tabulate_rsp_subgroups()
- Tabulate Binary Response by Subgroup
-
tabulate_survival_biomarkers()
- Tabulate Biomarker Effects on Survival by Subgroup
-
a_survival_subgroups()
tabulate_survival_subgroups()
- Tabulate Survival Duration by Subgroup
-
s_test_proportion_diff()
a_test_proportion_diff()
test_proportion_diff()
- Difference Test for Two Proportions
-
create_afun_compare()
- Constructor Function for
compare_vars()
-
create_afun_summary()
- Constructor Function for
summarize_vars()
andsummarize_colvars()
-
h_coxreg_inter_effect()
h_coxreg_extract_interaction()
h_coxreg_inter_estimations()
- Cox Regression Helper: Interactions
-
h_get_format_threshold()
h_format_threshold()
- Formatting Extreme Values
-
h_adlb_worsen()
- Helper Function to Prepare ADLB with Worst Labs
-
h_adsl_adlb_merge_using_worst_flag()
- Helper Function for Deriving Analysis Datasets for LBT13 and LBT14
-
h_ancova()
- Helper Function to Return Results of a Linear Model
-
h_append_grade_groups()
- Helper function for
s_count_occurrences_by_grade()
-
h_count_cumulative()
- Helper Function for
s_count_cumulative()
-
h_coxreg_univar_formulas()
h_coxreg_multivar_formula()
h_coxreg_univar_extract()
h_coxreg_multivar_extract()
- Helper Functions for Cox Proportional Hazards Regression
-
h_decompose_gg()
-
ggplot
Decomposition
-
h_format_row()
- Helper function to get the right formatting in the optional table in g_lineplot.
-
h_ggkm()
- Helper function: KM plot
-
h_km_layout()
- Helper: KM Layout
-
h_get_interaction_vars()
h_interaction_coef_name()
h_or_cat_interaction()
h_or_cont_interaction()
h_or_interaction()
h_simple_term_labels()
h_interaction_term_labels()
h_glm_simple_term_extract()
h_glm_interaction_extract()
h_glm_inter_term_extract()
h_logistic_simple_terms()
h_logistic_inter_terms()
- Helper Functions for Multi-Variable Logistic Regression
-
h_map_for_count_abnormal()
- Helper Function to create a map dataframe that can be used in
trim_levels_to_map
split function.
-
or_glm()
or_clogit()
- Helper Functions for Odds Ratio Estimation
-
h_pkparam_sort()
- Sort
PK PARAM
variable
-
prop_diff_wald()
prop_diff_ha()
prop_diff_nc()
prop_diff_cmh()
prop_diff_strat_nc()
- Helper Functions to Calculate Proportion Difference
-
prop_wilson()
prop_strat_wilson()
prop_clopper_pearson()
prop_wald()
prop_agresti_coull()
prop_jeffreys()
- Helper Functions for Calculating Proportion Confidence Intervals
-
h_rsp_to_logistic_variables()
h_logistic_mult_cont_df()
h_tab_rsp_one_biomarker()
- Helper Functions for Tabulating Biomarker Effects on Binary Response by Subgroup
-
h_proportion_df()
h_proportion_subgroups_df()
h_odds_ratio_df()
h_odds_ratio_subgroups_df()
- Helper Functions for Tabulating Binary Response by Subgroup
-
h_split_by_subgroups()
- Split Dataframe by Subgroups
-
h_split_param()
- Split parameters
-
h_stack_by_baskets()
- Helper Function to create a new
SMQ
variable inADAE
by stackingSMQ
and/orCQ
records.
-
h_step_window()
h_step_trt_effect()
h_step_survival_formula()
h_step_survival_est()
h_step_rsp_formula()
h_step_rsp_est()
- Helper Functions for Subgroup Treatment Effect Pattern (STEP) Calculations
-
h_surv_to_coxreg_variables()
h_coxreg_mult_cont_df()
h_tab_surv_one_biomarker()
- Helper Functions for Tabulating Biomarker Effects on Survival by Subgroup
-
h_survtime_df()
h_survtime_subgroups_df()
h_coxph_df()
h_coxph_subgroups_df()
- Helper Functions for Tabulating Survival Duration by Subgroup
-
h_tab_one_biomarker()
- Helper Function for Tabulation of a Single Biomarker Result
-
h_tbl_coxph_pairwise()
- Helper Function: Pairwise CoxPH table
-
h_tbl_median_surv()
- Helper Function: Survival Estimations
-
h_worsen_counter()
- Helper Function to Analyze Patients for
s_count_abnormal_lab_worsen_by_baseline()
Model-Specific Functions
These functions help with fitting or extracting results from specific models.
-
estimate_coef()
- Hazard Ratio Estimation in Interactions
-
extract_rsp_biomarkers()
- Prepares Response Data Estimates for Multiple Biomarkers in a Single Data Frame
-
extract_rsp_subgroups()
- Prepares Response Data for Population Subgroups in Data Frames
-
extract_survival_biomarkers()
- Prepares Survival Data Estimates for Multiple Biomarkers in a Single Data Frame
-
extract_survival_subgroups()
- Prepares Survival Data for Population Subgroups in Data Frames
-
fit_coxreg_univar()
fit_coxreg_multivar()
- Fits for Cox Proportional Hazards Regression
-
fit_logistic()
- Fit for Logistic Regression
-
fit_rsp_step()
- Subgroup Treatment Effect Pattern (STEP) Fit for Binary (Response) Outcome
-
fit_survival_step()
- Subgroup Treatment Effect Pattern (STEP) Fit for Survival Outcome
-
get_smooths()
- Smooth Function with Optional Grouping
-
logistic_regression_cols()
- Logistic Regression Multi-Variable Column Layout Function
-
logistic_summary_by_flag()
- Logistic Regression Summary Table Constructor Function
-
pairwise()
- Pairwise Formula Special Term
-
tidy(<glm>)
- Custom Tidy Method for Binomial GLM Results
-
tidy(<step>)
- Custom Tidy Method for STEP Results
-
tidy(<summary.coxph>)
tidy(<coxreg.univar>)
tidy(<coxreg.multivar>)
- Custom Tidy Methods for Cox Regression
-
univariate()
- Univariate Formula Special Term
-
g_forest()
- Create a Forest Plot based on a Table
-
g_km()
- Kaplan-Meier Plot
-
g_lineplot()
- Line plot with the optional table
-
g_step()
- Create a STEP Graph
-
g_waterfall()
- Horizontal Waterfall Plot
-
g_ipp()
- Individual Patient Plots
rtables Helper Functions
These functions help to work with the rtables
package and may be moved there later.
-
add_rowcounts()
- Layout Creating Function to Add Row Total Counts
-
append_varlabels()
- Add Variable Labels to Top Left Corner in Table
-
as.rtable()
- Convert to
rtable
-
combine_groups()
- Reference and Treatment Group Combination
-
combine_levels()
- Combine Factor Levels
-
combine_vectors()
- Combine Two Vectors Element Wise
-
h_col_indices()
- Obtain Column Indices
-
h_row_first_values()
h_row_counts()
h_row_fractions()
h_col_counts()
h_content_first_row()
is_leaf_table()
check_names_indices()
-
rtables
Access Helper Functions
-
split_cols_by_groups()
- Split Columns by Groups of Levels
-
to_string_matrix()
- Convert Table into Matrix of Strings
rtables Formatting Functions
These functions provide customized formatting rules to work with the rtables
package.
-
format_count_fraction()
- Formatting Count and Fraction
-
format_count_fraction_fixed_dp()
- Formatting Count and Percentage with Fixed Single Decimal Place
-
format_extreme_values()
- Formatting a Single Extreme Value
-
format_extreme_values_ci()
- Formatting Extreme Values Part of a Confidence Interval
-
format_fraction()
- Formatting Fraction and Percentage
-
format_fraction_fixed_dp()
- Formatting Fraction and Percentage with Fixed Single Decimal Place
-
format_fraction_threshold()
- Formatting Fraction with Lower Threshold
-
format_xx()
- Formatting: XX as Formatting Function
-
score_occurrences()
score_occurrences_cols()
score_occurrences_subtable()
score_occurrences_cont_cols()
- Occurrence Table Sorting
-
decorate_grob()
- Add Titles, Footnotes, Page Number, and a Bounding Box to a Grid Grob
-
decorate_grob_set()
- Decorate Set of
grobs
and Add Page Numbering
-
h_g_ipp()
- Helper Function To Create Simple Line Plot over Time
-
draw_grob()
- Draw
grob
-
h_grob_coxph()
- Helper Function: CoxPH Grob
-
h_grob_median_surv()
- Helper Function: Survival Estimation Grob
-
h_grob_tbl_at_risk()
- Helper: Patient-at-Risk Grobs
-
h_grob_y_annot()
- Helper: Grid Object with y-axis Annotation
-
stack_grobs()
- Stack Multiple Grobs
-
h_xticks()
- Helper function: x tick positions
-
aesi_label()
- Labels for Adverse Event Baskets
-
as_factor_keep_attributes()
- Conversion of a Vector to a Factor
-
bins_percent_labels()
- Labels for Bins in Percent
-
combine_levels()
- Combine Factor Levels
-
cut_quantile_bins()
- Cutting Numeric Vector into Empirical Quantile Bins
-
day2month()
- Conversion of Days to Months
-
df_explicit_na()
- Encode Categorical Missing Values in a Data Frame
-
d_count_abnormal_by_baseline()
- Description Function for
s_count_abnormal_by_baseline()
-
d_count_cumulative()
- Description of Cumulative Count
-
d_count_missed_doses()
- Description Function that Calculates Labels for
s_count_missed_doses()
.
-
d_onco_rsp_label()
- Description of Standard Oncology Response
-
d_pkparam()
- Generate PK reference dataset
-
d_proportion()
- Description of the Proportion Summary
-
d_proportion_diff()
- Description of Method Used for Proportion Comparison
-
d_rsp_subgroups_colvars()
- Labels for Column Variables in Binary Response by Subgroup Table
-
d_survival_subgroups_colvars()
- Labels for Column Variables in Survival Duration by Subgroup Table
-
d_test_proportion_diff()
- Description of the Difference Test Between Two Proportions
-
explicit_na()
- Missing Data
-
fct_collapse_only()
- Collapsing of Factor Levels and Keeping Only Those New Group Levels
-
fct_discard()
- Discard Certain Levels from a Factor
-
fct_explicit_na_if()
- Insertion of Explicit Missings in a Factor
-
f_conf_level()
- Utility function to create label for confidence interval
-
f_pval()
- Utility function to create label for p-value
-
h_data_plot()
- Helper function: tidy survival fit
-
month2day()
- Conversion of Months to Days
-
reapply_varlabels()
- Reapply Variable Labels
-
sas_na()
- Convert Strings to
NA
-
stat_mean_ci()
- Confidence Interval for Mean
-
stat_mean_pval()
- p-Value of the Mean
-
stat_median_ci()
- Confidence Interval for Median
-
strata_normal_quantile()
- Helper Function for the Estimation of Stratified Quantiles
-
to_n()
- Replicate Entries of a Vector if Required
-
update_weights_strat_wilson()
- Helper Function for the Estimation of Weights for
prop_strat_wilson
-
assert_list_of_variables()
assert_df_with_variables()
assert_valid_factor()
assert_df_with_factors()
assert_proportion_value()
- Additional Assertions for
checkmate
-
tern_ex_adsl
tern_ex_adae
tern_ex_adlb
tern_ex_adpp
tern_ex_adrs
tern_ex_adtte
- Simulated CDISC Data for Examples