Package: tern 0.9.5

Joe Zhu

tern: Create Common TLGs Used in Clinical Trials

Table, Listings, and Graphs (TLG) library for common outputs used in clinical trials.

Authors:Joe Zhu [aut, cre], Daniel Sabanés Bové [aut], Jana Stoilova [aut], Davide Garolini [aut], Emily de la Rua [aut], Abinaya Yogasekaram [aut], Heng Wang [aut], Francois Collin [aut], Adrian Waddell [aut], Pawel Rucki [aut], Chendi Liao [aut], Jennifer Li [aut], F. Hoffmann-La Roche AG [cph, fnd]

tern_0.9.5.tar.gz
tern_0.9.5.zip(r-4.5)tern_0.9.5.zip(r-4.4)tern_0.9.5.zip(r-4.3)
tern_0.9.5.tgz(r-4.4-any)tern_0.9.5.tgz(r-4.3-any)
tern_0.9.5.tar.gz(r-4.5-noble)tern_0.9.5.tar.gz(r-4.4-noble)
tern_0.9.5.tgz(r-4.4-emscripten)tern_0.9.5.tgz(r-4.3-emscripten)
tern.pdf |tern.html
tern/json (API)
NEWS

# Install 'tern' in R:
install.packages('tern', repos = c('https://insightsengineering.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/insightsengineering/tern/issues

Datasets:

On CRAN:

clinical-trialsgraphslistingsnestoutputstables

277 exports 72 stars 5.34 score 69 dependencies 7 dependents 518 downloads

Last updated 17 days agofrom:6d6da7092e (on v0.9.5)

Exports:a_count_occurrencesa_count_occurrences_by_gradea_count_patients_sum_exposurea_count_patients_with_eventa_count_patients_with_flagsa_count_valuesa_coxrega_length_proportiona_odds_ratioa_proportiona_proportion_diffa_summarya_surv_timeadd_riskdiffadd_rowcountsaesi_labelanalyze_num_patientsanalyze_patients_exposure_in_colsanalyze_varsanalyze_vars_in_colsappend_varlabelsarrange_grobsas.rtableCombinationFunctioncombine_countscombine_groupscombine_levelscombine_vectorscompare_varscontrol_analyze_varscontrol_coxphcontrol_coxph_annotcontrol_coxregcontrol_incidence_ratecontrol_lineplot_varscontrol_logisticcontrol_stepcontrol_surv_med_annotcontrol_surv_timecontrol_surv_timepointcount_abnormalcount_abnormal_by_baselinecount_abnormal_by_markedcount_abnormal_by_worst_gradecount_abnormal_lab_worsen_by_baselinecount_cumulativecount_missed_dosescount_occurrencescount_occurrences_by_gradecount_patients_with_eventcount_patients_with_flagscount_valuescoxph_pairwisecut_quantile_binsd_count_abnormal_by_baselined_count_cumulatived_count_missed_dosesd_onco_rsp_labeld_pkparamd_proportiond_proportion_diffd_rsp_subgroups_colvarsd_survival_subgroups_colvarsd_test_proportion_diffday2monthdecorate_grobdecorate_grob_setdefault_na_strdf_explicit_nadraw_grobestimate_incidence_rateestimate_multinomial_responseestimate_odds_ratioestimate_proportionestimate_proportion_diffexplicit_naextract_rsp_biomarkersextract_rsp_subgroupsextract_survival_biomarkersextract_survival_subgroupsf_conf_levelf_pvalfct_collapse_onlyfct_discardfct_explicit_na_iffit_coxreg_multivarfit_coxreg_univarfit_logisticfit_rsp_stepfit_survival_stepforest_viewportformat_autoformat_count_fractionformat_count_fraction_fixed_dpformat_count_fraction_lt10format_extreme_valuesformat_extreme_values_ciformat_fractionformat_fraction_fixed_dpformat_fraction_thresholdformat_sigfigformat_xxg_bland_altmang_forestg_ippg_kmg_lineplotg_stepg_waterfallget_formats_from_statsget_indents_from_statsget_labels_from_statsget_smoothsget_statsgroups_list_to_dfh_adlb_abnormal_by_worst_gradeh_adlb_worsenh_adsl_adlb_merge_using_worst_flagh_ancovah_append_grade_groupsh_col_countsh_col_indicesh_content_first_rowh_count_cumulativeh_coxph_dfh_coxph_subgroups_dfh_coxreg_extract_interactionh_coxreg_inter_effecth_coxreg_inter_estimationsh_coxreg_mult_cont_dfh_coxreg_multivar_extracth_coxreg_multivar_formulah_coxreg_univar_extracth_coxreg_univar_formulash_data_ploth_decompose_ggh_format_rowh_format_thresholdh_g_ipph_get_format_thresholdh_get_interaction_varsh_ggkmh_glm_inter_term_extracth_glm_interaction_extracth_glm_simple_term_extracth_grob_coxphh_grob_median_survh_grob_tbl_at_riskh_grob_y_annoth_incidence_rate_byarh_incidence_rate_exacth_incidence_rate_normalh_incidence_rate_normal_logh_interaction_coef_nameh_interaction_term_labelsh_km_layouth_logistic_inter_termsh_logistic_mult_cont_dfh_logistic_simple_termsh_map_for_count_abnormalh_odds_ratio_dfh_odds_ratio_subgroups_dfh_or_cat_interactionh_or_cont_interactionh_or_interactionh_pkparam_sorth_proportion_dfh_proportion_subgroups_dfh_row_countsh_row_first_valuesh_row_fractionsh_rsp_to_logistic_variablesh_simple_term_labelsh_split_by_subgroupsh_split_paramh_stack_by_basketsh_step_rsp_esth_step_rsp_formulah_step_survival_esth_step_survival_formulah_step_trt_effecth_step_windowh_surv_to_coxreg_variablesh_survtime_dfh_survtime_subgroups_dfh_tab_one_biomarkerh_tab_rsp_one_biomarkerh_tab_surv_one_biomarkerh_tbl_coxph_pairwiseh_tbl_median_survh_worsen_counterh_xtickshas_count_in_any_colhas_count_in_colshas_counts_differencehas_fraction_in_any_colhas_fraction_in_colshas_fractions_differenceimputation_rulekeep_content_rowskeep_rowslabels_use_controllevel_orderlogistic_regression_colslogistic_summary_by_flagmonth2dayor_clogitor_glmprop_agresti_coullprop_clopper_pearsonprop_diff_cmhprop_diff_haprop_diff_ncprop_diff_strat_ncprop_diff_waldprop_jeffreysprop_strat_wilsonprop_waldprop_wilsonreapply_varlabelsref_group_positionrtable2ggs_bland_altmans_compares_count_occurrencess_count_occurrences_by_grades_count_patients_with_events_count_patients_with_flagss_count_valuess_coxregs_length_proportions_num_patientss_num_patients_contents_odds_ratios_proportions_proportion_diffs_summarysas_nascore_occurrencesscore_occurrences_colsscore_occurrences_cont_colsscore_occurrences_subtableset_default_na_strsplit_cols_by_groupsstack_grobsstat_mean_cistat_mean_pvalstat_median_cistat_propdiff_cistrata_normal_quantilesummarize_ancovasummarize_changesummarize_colvarssummarize_coxregsummarize_glm_countsummarize_logisticsummarize_num_patientssummarize_occurrencessummarize_occurrences_by_gradesummarize_patients_events_in_colssummarize_patients_exposure_in_colssummary_formatssummary_labelssurv_timesurv_timepointtabulate_rsp_biomarkerstabulate_rsp_subgroupstabulate_survival_biomarkerstabulate_survival_subgroupstern_default_formatstern_default_labelstern_default_statstest_proportion_diffto_nto_string_matrixunivariateupdate_weights_strat_wilson

Dependencies:abindbackportsbase64encbootbroomcarcarDatacheckmateclicolorspacecowplotcpp11digestdplyremmeansestimabilityfansifarverfastmapforcatsformattersgenericsggplot2gluegridExtragtablehtmltoolsisobandlabelinglatticelifecyclelme4magrittrMASSMatrixMatrixModelsmgcvminqamunsellmvtnormnlmenloptrnnetnumDerivpbkrtestpillarpkgconfigpurrrquantregR6rbibutilsRColorBrewerRcppRcppEigenRdpackrlangrtablesscalesSparseMstringistringrsurvivaltibbletidyrtidyselectutf8vctrsviridisLitewithr

Formatting Functions

Rendered fromtern_formats.Rmdusingknitr::rmarkdownon Jun 21 2024.

Last update: 2023-01-16
Started: 2023-01-16

Introduction to tern

Rendered fromtern.Rmdusingknitr::rmarkdownon Jun 21 2024.

Last update: 2024-04-12
Started: 2022-03-10

Missing Values in Tern

Rendered frommissing_values.Rmdusingknitr::rmarkdownon Jun 21 2024.

Last update: 2023-07-04
Started: 2023-04-13

Tabulation

Rendered fromtables.Rmdusingknitr::rmarkdownon Jun 21 2024.

Last update: 2024-04-12
Started: 2022-03-10

Readme and manuals

Help Manual

Help pageTopics
tern Packagetern-package tern
Split function to configure risk difference columnadd_riskdiff
Layout-creating function to add row total countsadd_rowcounts
Labels for adverse event basketsaesi_label
Analyze functions on columnsanalyze_colvars_functions
Analyze functionsanalyze_functions
Analyze variablesanalyze_variables analyze_vars a_summary s_summary s_summary.character s_summary.factor s_summary.logical s_summary.numeric
Summarize numeric variables in columnsanalyze_vars_in_cols
Add variable labels to top left corner in tableappend_varlabels
Arrange multiple grobsarrange_grobs
Convert to 'rtable'as.rtable as.rtable.data.frame
Bland-Altman analysisbland_altman g_bland_altman s_bland_altman
Class for 'CombinationFunction'!,CombinationFunction-method &,CombinationFunction,CombinationFunction-method CombinationFunction CombinationFunction-class combination_function |,CombinationFunction,CombinationFunction-method
Combine countscombine_counts
Reference and treatment group combinationcombine_groups
Combine factor levelscombine_levels
Element-wise combination of two vectorscombine_vectors
Compare variables between groupscompare_variables compare_vars s_compare s_compare.character s_compare.factor s_compare.logical s_compare.numeric
Control function for descriptive statisticscontrol_analyze_vars
Control functions for Kaplan-Meier plot annotation tablescontrol_annot control_coxph_annot control_surv_med_annot
Control function for Cox-PH modelcontrol_coxph
Control function for Cox regressioncontrol_coxreg
Control function for incidence ratecontrol_incidence_rate
Control function for 'g_lineplot()'control_lineplot_vars
Control function for logistic regression model fittingcontrol_logistic
Control function for subgroup treatment effect pattern (STEP) calculationscontrol_step
Control function for 'survfit' models for survival timecontrol_surv_time
Control function for 'survfit' models for patients' survival rate at time pointscontrol_surv_timepoint
Occurrence countsa_count_occurrences count_occurrences summarize_occurrences s_count_occurrences
Occurrence counts by gradea_count_occurrences_by_grade count_occurrences_by_grade summarize_occurrences_by_grade s_count_occurrences_by_grade
Count the number of patients with a particular eventa_count_patients_with_event count_patients_with_event s_count_patients_with_event
Count the number of patients with particular flagsa_count_patients_with_flags count_patients_with_flags s_count_patients_with_flags
Count specific valuesa_count_values count_values count_values_funs s_count_values s_count_values.character s_count_values.factor s_count_values.logical
Cox proportional hazards regressiona_coxreg cox_regression summarize_coxreg s_coxreg
Cox regression helper function for interactionscox_regression_inter h_coxreg_extract_interaction h_coxreg_inter_effect h_coxreg_inter_effect.character h_coxreg_inter_effect.factor h_coxreg_inter_effect.numeric h_coxreg_inter_estimations
Cut numeric vector into empirical quantile binscut_quantile_bins
Description function for 's_count_abnormal_by_baseline()'d_count_abnormal_by_baseline
Description of cumulative countd_count_cumulative
Description function that calculates labels for 's_count_missed_doses()'d_count_missed_doses
Description of standard oncology responsed_onco_rsp_label
Generate PK reference datasetd_pkparam
Description of the proportion summaryd_proportion
Description of method used for proportion comparisond_proportion_diff
Labels for column variables in binary response by subgroup tabled_rsp_subgroups_colvars
Labels for column variables in survival duration by subgroup tabled_survival_subgroups_colvars
Description of the difference test between two proportionsd_test_proportion_diff
Conversion of days to monthsday2month
Add titles, footnotes, page Number, and a bounding box to a grid grobdecorate_grob
Decorate set of 'grob's and add page numberingdecorate_grob_set
Default string replacement for 'NA' valuesdefault_na_str set_default_na_str
Get default statistical methods and their associated formats, labels, and indent modifiersdefault_stats_formats_labels get_formats_from_stats get_indents_from_stats get_labels_from_stats get_stats summary_formats summary_labels tern_default_formats tern_default_labels tern_default_stats
Encode categorical missing values in a data framedf_explicit_na
Draw 'grob'draw_grob
Estimation of proportions per level of factora_length_proportion estimate_multinomial_response estimate_multinomial_rsp s_length_proportion
Estimation of proportionsa_proportion estimate_proportion estimate_proportions s_proportion
Simulated CDISC data for examplesex_data tern_ex_adae tern_ex_adlb tern_ex_adpp tern_ex_adrs tern_ex_adsl tern_ex_adtte
Missing dataexplicit_na
Prepare response data estimates for multiple biomarkers in a single data frameextract_rsp_biomarkers
Prepare response data for population subgroups in data framesextract_rsp_subgroups
Prepare survival data estimates for multiple biomarkers in a single data frameextract_survival_biomarkers
Prepare survival data for population subgroups in data framesextract_survival_subgroups
Format extreme valuesextreme_format h_format_threshold h_get_format_threshold
Utility function to create label for confidence intervalf_conf_level
Utility function to create label for p-valuef_pval
Collapse factor levels and keep only those new group levelsfct_collapse_only
Discard specified levels of a factorfct_discard
Insertion of explicit missing values in a factorfct_explicit_na_if
Fitting functions for Cox proportional hazards regressionfit_coxreg fit_coxreg_multivar fit_coxreg_univar
Fit for logistic regressionfit_logistic
Subgroup treatment effect pattern (STEP) fit for binary (response) outcomefit_rsp_step
Subgroup treatment effect pattern (STEP) fit for survival outcomefit_survival_step
Create a viewport tree for the forest plotforest_viewport
Format automatically using data significant digitsformat_auto
Format count and fractionformat_count_fraction
Format count and percentage with fixed single decimal placeformat_count_fraction_fixed_dp
Format count and fraction with special case for count < 10format_count_fraction_lt10
Format a single extreme valueformat_extreme_values
Format extreme values part of a confidence intervalformat_extreme_values_ci
Format fraction and percentageformat_fraction
Format fraction and percentage with fixed single decimal placeformat_fraction_fixed_dp
Format fraction with lower thresholdformat_fraction_threshold
Format numeric values by significant figuresformat_sigfig
Format XX as a formatting functionformat_xx
Formatting functionsformatting_functions
Create a forest plot from an 'rtable'g_forest
Individual patient plotsg_ipp individual_patient_plot
Kaplan-Meier plotg_km kaplan_meier
Line plot with optional tableg_lineplot
Create a STEP graphg_step
Horizontal waterfall plotg_waterfall
Smooth function with optional groupingget_smooths
Convert list of groups to a data framegroups_list_to_df
Helper function to prepare ADLB for 'count_abnormal_by_worst_grade()'h_adlb_abnormal_by_worst_grade
Helper function to prepare ADLB with worst labsh_adlb_worsen
Helper function for deriving analysis datasets for select laboratory tablesh_adsl_adlb_merge_using_worst_flag
Helper function to return results of a linear modelh_ancova
Helper function for 's_count_occurrences_by_grade()'h_append_grade_groups
Obtain column indicesh_col_indices
Helper function for 's_count_cumulative()'h_count_cumulative
Helper functions for Cox proportional hazards regressionh_coxreg_multivar_extract h_coxreg_multivar_formula h_coxreg_univar_extract h_coxreg_univar_formulas h_cox_regression
Helper function to tidy survival fit datah_data_plot
'ggplot' decompositionh_decompose_gg
Helper function to format the optional 'g_lineplot' tableh_format_row
Helper function to create simple line plot over timeh_g_ipp
Helper function to create a KM ploth_ggkm
Helper function to create Cox-PH grobsh_grob_coxph
Helper function to create survival estimation grobsh_grob_median_surv
Helper function to create patient-at-risk grobsh_grob_tbl_at_risk
Helper function to create grid object with y-axis annotationh_grob_y_annot
Helper function to prepare a KM layouth_km_layout
Helper functions for multivariate logistic regressionh_get_interaction_vars h_glm_interaction_extract h_glm_inter_term_extract h_glm_simple_term_extract h_interaction_coef_name h_interaction_term_labels h_logistic_inter_terms h_logistic_regression h_logistic_simple_terms h_or_cat_interaction h_or_cont_interaction h_or_interaction h_simple_term_labels
Helper function to create a map data frame for 'trim_levels_to_map()'h_map_for_count_abnormal
Helper functions for odds ratio estimationh_odds_ratio or_clogit or_glm
Sort pharmacokinetic data by 'PARAM' variableh_pkparam_sort
Helper functions to calculate proportion differenceh_prop_diff prop_diff_cmh prop_diff_ha prop_diff_nc prop_diff_strat_nc prop_diff_wald
Helper functions for calculating proportion confidence intervalsh_proportions prop_agresti_coull prop_clopper_pearson prop_jeffreys prop_strat_wilson prop_wald prop_wilson
Helper functions for tabulating biomarker effects on binary response by subgrouph_logistic_mult_cont_df h_response_biomarkers_subgroups h_rsp_to_logistic_variables h_tab_rsp_one_biomarker
Helper functions for tabulating binary response by subgrouph_odds_ratio_df h_odds_ratio_subgroups_df h_proportion_df h_proportion_subgroups_df h_response_subgroups
Split data frame by subgroupsh_split_by_subgroups
Split parametersh_split_param
Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records.h_stack_by_baskets
Helper functions for subgroup treatment effect pattern (STEP) calculationsh_step h_step_rsp_est h_step_rsp_formula h_step_survival_est h_step_survival_formula h_step_trt_effect h_step_window
Helper functions for tabulating biomarker effects on survival by subgrouph_coxreg_mult_cont_df h_survival_biomarkers_subgroups h_surv_to_coxreg_variables h_tab_surv_one_biomarker
Helper functions for tabulating survival duration by subgrouph_coxph_df h_coxph_subgroups_df h_survival_duration_subgroups h_survtime_df h_survtime_subgroups_df
Helper function for tabulation of a single biomarker resulth_tab_one_biomarker
Helper function for generating a pairwise Cox-PH tableh_tbl_coxph_pairwise
Helper function for survival estimationsh_tbl_median_surv
Helper function to analyze patients for 's_count_abnormal_lab_worsen_by_baseline()'h_worsen_counter
Helper function to calculate x-tick positionsh_xticks
Apply 1/3 or 1/2 imputation rule to dataimputation_rule
Update labels according to control specificationslabels_use_control
Logistic regression multivariate column layout functionlogistic_regression_cols
Logistic regression summary tablelogistic_summary_by_flag
Conversion of months to daysmonth2day
Odds ratio estimationa_odds_ratio estimate_odds_ratio odds_ratio s_odds_ratio
Proportion differencea_proportion_diff estimate_proportion_diff prop_diff s_proportion_diff
Occurrence table pruninghas_counts_difference has_count_in_any_col has_count_in_cols has_fractions_difference has_fraction_in_any_col has_fraction_in_cols keep_content_rows keep_rows prune_occurrences
Reapply variable labelsreapply_varlabels
Tabulate biomarker effects on binary response by subgroupresponse_biomarkers_subgroups tabulate_rsp_biomarkers
Convert 'rtable' objects to 'ggplot' objectsrtable2gg
Convert strings to 'NA'sas_na
Occurrence table sortingscore_occurrences score_occurrences_cols score_occurrences_cont_cols score_occurrences_subtable
Split columns by groups of levelssplit_cols_by_groups
Stack multiple grobsstack_grobs
Confidence interval for meanstat_mean_ci
p-Value of the meanstat_mean_pval
Confidence interval for medianstat_median_ci
Proportion difference and confidence intervalstat_propdiff_ci
Helper function for the estimation of stratified quantilesstrata_normal_quantile
Summarize variables in columnssummarize_colvars
Summarize functionssummarize_functions
Multivariate logistic regression tablesummarize_logistic
Number of patientsanalyze_num_patients summarize_num_patients s_num_patients s_num_patients_content
Tabulate biomarker effects on survival by subgroupsurvival_biomarkers_subgroups tabulate_survival_biomarkers
Custom tidy methods for Cox regressiontidy.coxreg.multivar tidy.coxreg.univar tidy.summary.coxph tidy_coxreg
Custom tidy method for binomial GLM resultstidy.glm
Custom tidy method for STEP resultstidy.step
Replicate entries of a vector if requiredto_n
Convert table into matrix of stringsto_string_matrix
Univariate formula special termunivariate
Helper function for the estimation of weights for 'prop_strat_wilson()'update_weights_strat_wilson
Custom split functionslevel_order ref_group_position utils_split_funs