├── .Rbuildignore
├── .github
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE
│ ├── bug.yml
│ ├── config.yml
│ ├── cran-release.yml
│ ├── feature.yml
│ └── release.yml
├── pull_request_template.md
└── workflows
│ ├── check.yaml
│ ├── cla.yaml
│ ├── docs.yaml
│ ├── post-release.yaml
│ ├── release.yaml
│ └── scheduled.yaml
├── .gitignore
├── .gitlab-ci.yml
├── .lintr
├── .pre-commit-config.yaml
├── .revdeprefs.yaml
├── DESCRIPTION
├── LICENSE
├── NAMESPACE
├── NEWS.md
├── R
├── abnormal.R
├── abnormal_by_baseline.R
├── abnormal_by_marked.R
├── abnormal_by_worst_grade.R
├── abnormal_lab_worsen_by_baseline.R
├── analyze_colvars_functions.R
├── analyze_functions.R
├── analyze_variables.R
├── analyze_vars_in_cols.R
├── argument_convention.R
├── bland_altman.R
├── combination_function.R
├── compare_variables.R
├── control_incidence_rate.R
├── control_logistic.R
├── control_step.R
├── control_survival.R
├── count_cumulative.R
├── count_missed_doses.R
├── count_occurrences.R
├── count_occurrences_by_grade.R
├── count_patients_events_in_cols.R
├── count_patients_with_event.R
├── count_patients_with_flags.R
├── count_values.R
├── cox_regression.R
├── cox_regression_inter.R
├── coxph.R
├── d_pkparam.R
├── data.R
├── decorate_grob.R
├── desctools_binom_diff.R
├── df_explicit_na.R
├── estimate_multinomial_rsp.R
├── estimate_proportion.R
├── fit_rsp_step.R
├── fit_survival_step.R
├── formatting_functions.R
├── g_forest.R
├── g_ipp.R
├── g_km.R
├── g_lineplot.R
├── g_step.R
├── g_waterfall.R
├── h_adsl_adlb_merge_using_worst_flag.R
├── h_biomarkers_subgroups.R
├── h_cox_regression.R
├── h_incidence_rate.R
├── h_km.R
├── h_logistic_regression.R
├── h_map_for_count_abnormal.R
├── h_pkparam_sort.R
├── h_response_biomarkers_subgroups.R
├── h_response_subgroups.R
├── h_stack_by_baskets.R
├── h_step.R
├── h_survival_biomarkers_subgroups.R
├── h_survival_duration_subgroups.R
├── imputation_rule.R
├── incidence_rate.R
├── logistic_regression.R
├── missing_data.R
├── odds_ratio.R
├── package.R
├── prop_diff.R
├── prop_diff_test.R
├── prune_occurrences.R
├── response_biomarkers_subgroups.R
├── response_subgroups.R
├── riskdiff.R
├── rtables_access.R
├── score_occurrences.R
├── split_cols_by_groups.R
├── stat.R
├── summarize_ancova.R
├── summarize_change.R
├── summarize_colvars.R
├── summarize_coxreg.R
├── summarize_functions.R
├── summarize_glm_count.R
├── summarize_num_patients.R
├── summarize_patients_exposure_in_cols.R
├── survival_biomarkers_subgroups.R
├── survival_coxph_pairwise.R
├── survival_duration_subgroups.R
├── survival_time.R
├── survival_timepoint.R
├── utils.R
├── utils_checkmate.R
├── utils_default_stats_formats_labels.R
├── utils_factor.R
├── utils_ggplot.R
├── utils_grid.R
├── utils_rtables.R
└── utils_split_funs.R
├── README.md
├── SECURITY.md
├── _pkgdown.yml
├── data-raw
└── generate_tern_data.Rmd
├── data
├── tern_ex_adae.rda
├── tern_ex_adlb.rda
├── tern_ex_adpp.rda
├── tern_ex_adrs.rda
├── tern_ex_adsl.rda
└── tern_ex_adtte.rda
├── inst
├── REFERENCES.bib
└── WORDLIST
├── man
├── abnormal.Rd
├── abnormal_by_baseline.Rd
├── abnormal_by_marked.Rd
├── abnormal_by_worst_grade.Rd
├── abnormal_lab_worsen_by_baseline.Rd
├── add_riskdiff.Rd
├── add_rowcounts.Rd
├── aesi_label.Rd
├── afun_riskdiff.Rd
├── afun_selected_stats.Rd
├── analyze_colvars_functions.Rd
├── analyze_functions.Rd
├── analyze_variables.Rd
├── analyze_vars_in_cols.Rd
├── append_varlabels.Rd
├── apply_auto_formatting.Rd
├── argument_convention.Rd
├── arrange_grobs.Rd
├── as.rtable.Rd
├── assertions.Rd
├── bins_percent_labels.Rd
├── c_label_n.Rd
├── c_label_n_alt.Rd
├── cfun_by_flag.Rd
├── check_diff_prop_ci.Rd
├── check_same_n.Rd
├── combination_function.Rd
├── combine_counts.Rd
├── combine_groups.Rd
├── combine_vectors.Rd
├── compare_variables.Rd
├── control_analyze_vars.Rd
├── control_annot.Rd
├── control_coxph.Rd
├── control_coxreg.Rd
├── control_incidence_rate.Rd
├── control_lineplot_vars.Rd
├── control_logistic.Rd
├── control_riskdiff.Rd
├── control_step.Rd
├── control_surv_time.Rd
├── control_surv_timepoint.Rd
├── count_cumulative.Rd
├── count_missed_doses.Rd
├── count_occurrences.Rd
├── count_occurrences_by_grade.Rd
├── count_patients_events_in_cols.Rd
├── count_patients_with_event.Rd
├── count_patients_with_flags.Rd
├── count_values.Rd
├── cox_regression.Rd
├── cox_regression_inter.Rd
├── cut_quantile_bins.Rd
├── d_count_abnormal_by_baseline.Rd
├── d_count_cumulative.Rd
├── d_count_missed_doses.Rd
├── d_onco_rsp_label.Rd
├── d_pkparam.Rd
├── d_proportion.Rd
├── d_proportion_diff.Rd
├── d_rsp_subgroups_colvars.Rd
├── d_survival_subgroups_colvars.Rd
├── d_test_proportion_diff.Rd
├── day2month.Rd
├── decorate_grob.Rd
├── decorate_grob_factory.Rd
├── decorate_grob_set.Rd
├── default_na_str.Rd
├── default_stats_formats_labels.Rd
├── desctools_binom.Rd
├── df2gg.Rd
├── df_explicit_na.Rd
├── dot-is_equal_float.Rd
├── draw_grob.Rd
├── empty_vector_if_na.Rd
├── estimate_coef.Rd
├── estimate_multinomial_rsp.Rd
├── estimate_proportion.Rd
├── ex_data.Rd
├── explicit_na.Rd
├── extract_by_name.Rd
├── extract_rsp_biomarkers.Rd
├── extract_rsp_subgroups.Rd
├── extract_survival_biomarkers.Rd
├── extract_survival_subgroups.Rd
├── extreme_format.Rd
├── f_conf_level.Rd
├── f_pval.Rd
├── factor_utils.Rd
├── figures
│ ├── lifecycle-archived.svg
│ ├── lifecycle-defunct.svg
│ ├── lifecycle-deprecated.svg
│ ├── lifecycle-experimental.svg
│ ├── lifecycle-maturing.svg
│ ├── lifecycle-questioning.svg
│ ├── lifecycle-soft-deprecated.svg
│ ├── lifecycle-stable.svg
│ ├── lifecycle-superseded.svg
│ └── logo.png
├── fit_coxreg.Rd
├── fit_logistic.Rd
├── fit_rsp_step.Rd
├── fit_survival_step.Rd
├── forest_viewport.Rd
├── format_auto.Rd
├── format_count_fraction.Rd
├── format_count_fraction_fixed_dp.Rd
├── format_count_fraction_lt10.Rd
├── format_extreme_values.Rd
├── format_extreme_values_ci.Rd
├── format_fraction.Rd
├── format_fraction_fixed_dp.Rd
├── format_fraction_threshold.Rd
├── format_sigfig.Rd
├── format_xx.Rd
├── formatting_functions.Rd
├── g_bland_altman.Rd
├── g_forest.Rd
├── g_ipp.Rd
├── g_km.Rd
├── g_lineplot.Rd
├── g_step.Rd
├── g_waterfall.Rd
├── get_covariates.Rd
├── get_smooths.Rd
├── groups_list_to_df.Rd
├── h_adlb_abnormal_by_worst_grade.Rd
├── h_adlb_worsen.Rd
├── h_adsl_adlb_merge_using_worst_flag.Rd
├── h_ancova.Rd
├── h_append_grade_groups.Rd
├── h_biomarkers_subgroups.Rd
├── h_col_indices.Rd
├── h_count_cumulative.Rd
├── h_cox_regression.Rd
├── h_data_plot.Rd
├── h_decompose_gg.Rd
├── h_format_row.Rd
├── h_g_ipp.Rd
├── h_ggkm.Rd
├── h_glm_count.Rd
├── h_grob_coxph.Rd
├── h_grob_median_surv.Rd
├── h_grob_tbl_at_risk.Rd
├── h_grob_y_annot.Rd
├── h_incidence_rate.Rd
├── h_km_layout.Rd
├── h_logistic_regression.Rd
├── h_map_for_count_abnormal.Rd
├── h_odds_ratio.Rd
├── h_pkparam_sort.Rd
├── h_ppmeans.Rd
├── h_prop_diff.Rd
├── h_prop_diff_test.Rd
├── h_proportions.Rd
├── h_response_biomarkers_subgroups.Rd
├── h_response_subgroups.Rd
├── h_split_by_subgroups.Rd
├── h_split_param.Rd
├── h_stack_by_baskets.Rd
├── h_step.Rd
├── h_survival_biomarkers_subgroups.Rd
├── h_survival_duration_subgroups.Rd
├── h_tbl_coxph_pairwise.Rd
├── h_tbl_median_surv.Rd
├── h_worsen_counter.Rd
├── h_xticks.Rd
├── imputation_rule.Rd
├── incidence_rate.Rd
├── labels_or_names.Rd
├── labels_use_control.Rd
├── logistic_regression_cols.Rd
├── logistic_summary_by_flag.Rd
├── make_names.Rd
├── month2day.Rd
├── muffled_car_anova.Rd
├── n_available.Rd
├── odds_ratio.Rd
├── prop_diff.Rd
├── prop_diff_test.Rd
├── prune_occurrences.Rd
├── range_noinf.Rd
├── reapply_varlabels.Rd
├── response_biomarkers_subgroups.Rd
├── response_subgroups.Rd
├── rtable2gg.Rd
├── rtables_access.Rd
├── s_bland_altman.Rd
├── s_cox_multivariate.Rd
├── sas_na.Rd
├── score_occurrences.Rd
├── split_cols_by_groups.Rd
├── split_text_grob.Rd
├── stack_grobs.Rd
├── stat_mean_ci.Rd
├── stat_mean_pval.Rd
├── stat_median_ci.Rd
├── stat_propdiff_ci.Rd
├── strata_normal_quantile.Rd
├── study_arm.Rd
├── summarize_ancova.Rd
├── summarize_change.Rd
├── summarize_colvars.Rd
├── summarize_functions.Rd
├── summarize_glm_count.Rd
├── summarize_logistic.Rd
├── summarize_num_patients.Rd
├── summarize_patients_exposure_in_cols.Rd
├── survival_biomarkers_subgroups.Rd
├── survival_coxph_pairwise.Rd
├── survival_duration_subgroups.Rd
├── survival_time.Rd
├── survival_timepoint.Rd
├── tern-package.Rd
├── tidy.glm.Rd
├── tidy.step.Rd
├── tidy_coxreg.Rd
├── to_n.Rd
├── to_string_matrix.Rd
├── try_car_anova.Rd
├── univariate.Rd
├── unlist_and_blank_na.Rd
├── update_weights_strat_wilson.Rd
├── util_handling_additional_fun_params.Rd
└── utils_split_funs.Rd
├── pkgdown
└── favicon
│ ├── apple-touch-icon-120x120.png
│ ├── apple-touch-icon-152x152.png
│ ├── apple-touch-icon-180x180.png
│ ├── apple-touch-icon-60x60.png
│ ├── apple-touch-icon-76x76.png
│ ├── apple-touch-icon.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ └── favicon.ico
├── revdep
└── .gitignore
├── tern.Rproj
├── tests
├── testthat.R
└── testthat
│ ├── _snaps
│ ├── abnormal.md
│ ├── abnormal_by_baseline.md
│ ├── abnormal_by_marked.md
│ ├── abnormal_by_worst_grade.md
│ ├── abnormal_lab_worsen_by_baseline.md
│ ├── analyze_variables.md
│ ├── analyze_vars_in_cols.md
│ ├── bland-altman.md
│ ├── bland-altman
│ │ └── g_bland_altman.svg
│ ├── compare_variables.md
│ ├── control_logistic.md
│ ├── control_step.md
│ ├── control_survival.md
│ ├── count_cumulative.md
│ ├── count_missed_doses.md
│ ├── count_occurrences.md
│ ├── count_occurrences_by_grade.md
│ ├── count_patients_events_in_cols.md
│ ├── count_patients_with_event.md
│ ├── count_patients_with_flags.md
│ ├── count_values.md
│ ├── coxph.md
│ ├── coxreg.md
│ ├── decorate_grob.md
│ ├── decorate_grob
│ │ └── deco_grob_text_wrap.svg
│ ├── desctools_binom_diff.md
│ ├── df_explicit_na.md
│ ├── estimate_multinomial_rsp.md
│ ├── estimate_proportion.md
│ ├── fit_rsp_step.md
│ ├── fit_survival_step.md
│ ├── formatting_functions.md
│ ├── g_forest
│ │ ├── g_forest.svg
│ │ ├── g_forest_custom_1.svg
│ │ ├── g_forest_custom_2.svg
│ │ ├── g_forest_custom_3.svg
│ │ ├── g_forest_or.svg
│ │ ├── g_forest_plot_only.svg
│ │ └── g_forest_table_only.svg
│ ├── g_km
│ │ ├── g_km_at_risk_title.svg
│ │ ├── g_km_ci_ribbon.svg
│ │ ├── g_km_crop_ylim.svg
│ │ ├── g_km_crop_ylim_failure.svg
│ │ ├── g_km_custom.svg
│ │ ├── g_km_custom_ylim.svg
│ │ ├── g_km_default.svg
│ │ ├── g_km_eq_lbls.svg
│ │ ├── g_km_plot_only.svg
│ │ ├── g_km_ref_group_coxph.svg
│ │ ├── g_km_table_only.svg
│ │ └── g_km_title_footer.svg
│ ├── g_lineplot
│ │ ├── g_lineplot.svg
│ │ ├── g_lineplot_cohorts.svg
│ │ ├── g_lineplot_facets.svg
│ │ ├── g_lineplot_factor_levels.svg
│ │ ├── g_lineplot_plot_only.svg
│ │ ├── g_lineplot_table_only.svg
│ │ ├── g_lineplot_w_stats.svg
│ │ ├── g_lineplot_xlim_ylim.svg
│ │ ├── g_lineplot_xticks.svg
│ │ └── g_lineplot_xticks_by.svg
│ ├── g_step.md
│ ├── g_step
│ │ ├── g_step.svg
│ │ └── g_step_custom.svg
│ ├── g_waterfall
│ │ ├── g_waterfall.svg
│ │ └── g_waterfall_decorated.svg
│ ├── h_adsl_adlb_merge_using_worst_flag.md
│ ├── h_biomarkers_subgroups.md
│ ├── h_format_row.md
│ ├── h_incidence_rate.md
│ ├── h_km.md
│ ├── h_logistic_regression.md
│ ├── h_map_for_count_abnormal.md
│ ├── h_pkparam_sort.md
│ ├── h_response_biomarkers_subgroups.md
│ ├── h_response_subgroups.md
│ ├── h_stack_by_baskets.md
│ ├── h_step.md
│ ├── h_survival_biomarkers_subgroups.md
│ ├── h_survival_duration_subgroups.md
│ ├── imputation_rule.md
│ ├── incidence_rate.md
│ ├── logistic_regression.md
│ ├── make_afun.md
│ ├── odds_ratio.md
│ ├── prop_diff.md
│ ├── prune_occurrences.md
│ ├── response_biomarkers_subgroups.md
│ ├── response_subgroups.md
│ ├── rtables_access.md
│ ├── score_occurrences.md
│ ├── split_cols_by_groups.md
│ ├── stat.md
│ ├── summarize_ancova.md
│ ├── summarize_change.md
│ ├── summarize_colvars.md
│ ├── summarize_coxreg.md
│ ├── summarize_glm_count.md
│ ├── summarize_num_patients.md
│ ├── summarize_patients_exposure_in_cols.md
│ ├── survival_biomarkers_subgroups.md
│ ├── survival_coxph_pairwise.md
│ ├── survival_duration_subgroups.md
│ ├── survival_time.md
│ ├── survival_timepoint.md
│ ├── test_proportion_diff.md
│ ├── utils.md
│ ├── utils_default_stats_formats_labels.md
│ ├── utils_factor.md
│ ├── utils_ggplot
│ │ ├── df2gg_cw.svg
│ │ ├── df2gg_default.svg
│ │ ├── df2gg_fs.svg
│ │ ├── rtable2gg_colsplits.svg
│ │ ├── rtable2gg_cw.svg
│ │ ├── rtable2gg_default.svg
│ │ ├── rtable2gg_fs.svg
│ │ └── rtable2gg_lblpad.svg
│ ├── utils_rtables.md
│ └── utils_split_fun.md
│ ├── setup-options.R
│ ├── setup.R
│ ├── test-abnormal.R
│ ├── test-abnormal_by_baseline.R
│ ├── test-abnormal_by_marked.R
│ ├── test-abnormal_by_worst_grade.R
│ ├── test-abnormal_lab_worsen_by_baseline.R
│ ├── test-analyze_variables.R
│ ├── test-analyze_vars_in_cols.R
│ ├── test-bland-altman.R
│ ├── test-combination_function.R
│ ├── test-compare_variables.R
│ ├── test-control_logistic.R
│ ├── test-control_step.R
│ ├── test-control_survival.R
│ ├── test-count_cumulative.R
│ ├── test-count_missed_doses.R
│ ├── test-count_occurrences.R
│ ├── test-count_occurrences_by_grade.R
│ ├── test-count_patients_events_in_cols.R
│ ├── test-count_patients_with_event.R
│ ├── test-count_patients_with_flags.R
│ ├── test-count_values.R
│ ├── test-coxph.R
│ ├── test-coxreg.R
│ ├── test-decorate_grob.R
│ ├── test-desctools_binom_diff.R
│ ├── test-df_explicit_na.R
│ ├── test-estimate_multinomial_rsp.R
│ ├── test-estimate_proportion.R
│ ├── test-fit_rsp_step.R
│ ├── test-fit_survival_step.R
│ ├── test-formatting_functions.R
│ ├── test-g_forest.R
│ ├── test-g_km.R
│ ├── test-g_lineplot.R
│ ├── test-g_step.R
│ ├── test-g_waterfall.R
│ ├── test-h_adsl_adlb_merge_using_worst_flag.R
│ ├── test-h_biomarkers_subgroups.R
│ ├── test-h_format_row.R
│ ├── test-h_incidence_rate.R
│ ├── test-h_km.R
│ ├── test-h_logistic_regression.R
│ ├── test-h_map_for_count_abnormal.R
│ ├── test-h_pkparam_sort.R
│ ├── test-h_response_biomarkers_subgroups.R
│ ├── test-h_response_subgroups.R
│ ├── test-h_stack_by_baskets.R
│ ├── test-h_step.R
│ ├── test-h_survival_biomarkers_subgroups.R
│ ├── test-h_survival_duration_subgroups.R
│ ├── test-imputation_rule.R
│ ├── test-incidence_rate.R
│ ├── test-individual_patient_plot.R
│ ├── test-logistic_regression.R
│ ├── test-make_afun.R
│ ├── test-odds_ratio.R
│ ├── test-prop_diff.R
│ ├── test-prune_occurrences.R
│ ├── test-response_biomarkers_subgroups.R
│ ├── test-response_subgroups.R
│ ├── test-rtables_access.R
│ ├── test-score_occurrences.R
│ ├── test-split_cols_by_groups.R
│ ├── test-stat.R
│ ├── test-summarize_ancova.R
│ ├── test-summarize_change.R
│ ├── test-summarize_colvars.R
│ ├── test-summarize_coxreg.R
│ ├── test-summarize_glm_count.R
│ ├── test-summarize_num_patients.R
│ ├── test-summarize_patients_exposure_in_cols.R
│ ├── test-survival_biomarkers_subgroups.R
│ ├── test-survival_coxph_pairwise.R
│ ├── test-survival_duration_subgroups.R
│ ├── test-survival_time.R
│ ├── test-survival_timepoint.R
│ ├── test-test_proportion_diff.R
│ ├── test-utils.R
│ ├── test-utils_checkmate.R
│ ├── test-utils_default_stats_formats_labels.R
│ ├── test-utils_factor.R
│ ├── test-utils_ggplot.R
│ ├── test-utils_grid.R
│ ├── test-utils_rtables.R
│ └── test-utils_split_fun.R
└── vignettes
├── missing_values.Rmd
├── tables.Rmd
├── tern.Rmd
├── tern_formats.Rmd
└── tern_functions_guide.Rmd
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | # cicd
2 | ^\.pre-commit-config\.yaml$
3 |
4 | # data
5 | ^data-raw$
6 |
7 | # doc
8 | ^CODE_OF_CONDUCT\.md$
9 | ^docs$
10 | LICENSE
11 | ^LICENSE\.md$
12 | ^SECURITY\.md$
13 |
14 | # git
15 | ^\.git$
16 | ^\.github$
17 | ^\.gitlab-ci\.yml$
18 |
19 | # lintr
20 | ^\.lintr$
21 |
22 | # pkgdown
23 | ^_pkgdown\.yml$
24 | pkgdown
25 | ^pkgdown$
26 |
27 | # rstudio
28 | ^.*\.Rproj$
29 | ^\.Rproj\.user$
30 |
31 | # staded dependencies
32 | ^staged_dependencies\.yaml$
33 |
34 | # others
35 | ^renv$
36 | ^renv\.lock$
37 | ^.revdeprefs\.yaml$
38 | ^revdep$
39 | ^\.covrignore$
40 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | ---
2 | blank_issues_enabled: false
3 |
4 | contact_links:
5 | - name: We are hiring!
6 | url: https://careers.gene.com/
7 | about: Genentech and Roche are hiring!
8 | - name: Pharmaverse
9 | url: https://pharmaverse.org/
10 | about: Related projects @ Pharmaverse.org
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: ✨ Feature Request
3 | description: Request or propose a new feature
4 | title: "[Feature Request]:
"
5 | labels: ["enhancement"]
6 | body:
7 | - type: textarea
8 | attributes:
9 | label: Feature description
10 | description: |
11 | Do not use this form to ask a question, or ask for assistance. Instead, ask on [Stackoverflow](https://stackoverflow.com/)\
12 | using the `nest-rtables` and `nest-tern` tags. Questions about a function's use will be closed without a response.\n\n
13 | Is your feature request related to a problem? Please describe with a clear and concise description of the problem. \n\n
14 | Could you describe the solution you would like? Please provide a clear and concise description of what you want to happen.
15 | validations:
16 | required: true
17 | - type: checkboxes
18 | id: code-of-conduct
19 | attributes:
20 | label: Code of Conduct
21 | description: By submitting this issue, you agree to follow our [Code of Conduct.](https://insightsengineering.github.io/tern/CODE_OF_CONDUCT.html)
22 | options:
23 | - label: I agree to follow this project's Code of Conduct.
24 | required: true
25 | - type: checkboxes
26 | id: contributor-guidelines
27 | attributes:
28 | label: Contribution Guidelines
29 | description: By submitting this issue, you agree to follow our [Contribution Guidelines.](https://insightsengineering.github.io/tern/CONTRIBUTING.html)
30 | options:
31 | - label: I agree to follow this project's Contribution Guidelines.
32 | required: true
33 | - type: checkboxes
34 | id: security-policy
35 | attributes:
36 | label: Security Policy
37 | description: By submitting this issue, you agree to follow our [Security Policy.](https://github.com/insightsengineering/tern/security/policy)
38 | options:
39 | - label: I agree to follow this project's Security Policy.
40 | required: true
41 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | # Pull Request
2 |
3 |
4 |
5 | Fixes #nnn
6 |
--------------------------------------------------------------------------------
/.github/workflows/cla.yaml:
--------------------------------------------------------------------------------
1 | name: CLA 🔏
2 |
3 | on:
4 | issue_comment:
5 | types:
6 | - created
7 | # For PRs that originate from forks
8 | pull_request_target:
9 | types:
10 | - opened
11 | - closed
12 | - synchronize
13 |
14 | jobs:
15 | CLA:
16 | name: CLA 📝
17 | uses: insightsengineering/.github/.github/workflows/cla.yaml@main
18 | secrets: inherit
19 |
--------------------------------------------------------------------------------
/.github/workflows/docs.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Docs 📚
3 |
4 | on:
5 | push:
6 | branches:
7 | - main
8 | paths:
9 | - "inst/templates/**"
10 | - "_pkgdown.*"
11 | - DESCRIPTION
12 | - "**.md"
13 | - "**.Rmd"
14 | - "man/**"
15 | - "LICENSE.*"
16 | - NAMESPACE
17 | pull_request:
18 | types:
19 | - opened
20 | - synchronize
21 | - reopened
22 | - ready_for_review
23 | branches:
24 | - main
25 | paths:
26 | - "inst/templates/**"
27 | - "_pkgdown.*"
28 | - DESCRIPTION
29 | - "**.md"
30 | - "**.Rmd"
31 | - "man/**"
32 | - "LICENSE.*"
33 | - NAMESPACE
34 | workflow_dispatch:
35 |
36 | jobs:
37 | docs:
38 | name: Pkgdown Docs 📚
39 | uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main
40 | secrets:
41 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
42 | with:
43 | deps-installation-method: setup-r-dependencies
44 | default-landing-page: latest-tag
45 | additional-unit-test-report-directories: unit-test-report-non-cran
46 |
--------------------------------------------------------------------------------
/.github/workflows/post-release.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Post release ✨
3 |
4 | on:
5 | release:
6 | types: ["released"]
7 |
8 | jobs:
9 | vbump:
10 | name: Version Bump 🤜🤛
11 | uses: insightsengineering/r.pkg.template/.github/workflows/version-bump.yaml@main
12 | secrets:
13 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
14 | with:
15 | vbump-after-release: true
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # R-related
2 | .Rproj.user
3 | .Rhistory
4 | .RData
5 | .Ruserdata
6 |
7 | # docs
8 | inst/doc
9 | docs
10 |
11 | # tests
12 | tests/testthat/Rplots.pdf
13 |
14 | # others
15 | .DS_Store
16 | InputVads.Rdata
17 | t_ae_ctc_SE.out
18 | t_ae_ctc_ATEZOREL_SENBX.out
19 | temp/
20 |
21 | tests/testthat/_snaps/**/*.new.md
22 | tests/testthat/_snaps/**/*.new.svg
23 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | include:
4 | - project: 'nest/automation/gitlab-shared-library'
5 | ref: main
6 | file: R/R_NEST_min.gitlab-ci.yml
7 |
--------------------------------------------------------------------------------
/.lintr:
--------------------------------------------------------------------------------
1 | linters: linters_with_defaults(
2 | line_length_linter = line_length_linter(120),
3 | cyclocomp_linter = NULL,
4 | object_usage_linter = NULL,
5 | object_length_linter = NULL
6 | )
7 |
--------------------------------------------------------------------------------
/.revdeprefs.yaml:
--------------------------------------------------------------------------------
1 | - insightsengineering/chevron
2 | - insightsengineering/teal.modules.clinical
3 | - insightsengineering/scda.test
4 | - insightsengineering/autoslider.core
5 | - insightsengineering/tern.gee
6 | - insightsengineering/tern.mmrm
7 | - insightsengineering/tern.rbmi
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2022 F. Hoffmann-La Roche AG
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/R/analyze_colvars_functions.R:
--------------------------------------------------------------------------------
1 | #' Analyze functions in columns
2 | #'
3 | #' @description
4 | #' These functions are wrappers of [rtables::analyze_colvars()] which apply corresponding `tern`
5 | #' statistics functions to add an analysis to a given table layout. In particular, these functions
6 | #' where designed to have the analysis methods split into different columns.
7 | #'
8 | #' * [analyze_vars_in_cols()]: fundamental tabulation of analysis methods onto columns.
9 | #' In other words, the analysis methods are defined in the column space, i.e. they become
10 | #' column labels. By changing the variable vector, the list of functions can be applied on
11 | #' different variables, with the caveat of having the same number of statistical functions.
12 | #'
13 | #' * [tabulate_rsp_subgroups()]: similarly to `analyze_vars_in_cols`, this
14 | #' function combines `analyze_colvars` and `summarize_row_groups` in a compact way
15 | #' to produce standard tables that show analysis methods as columns.
16 | #' * [tabulate_survival_subgroups()]: this function is very similar to the above, but
17 | #' it is used for other tables.
18 | #'
19 | #' * [analyze_patients_exposure_in_cols()]: based only on `analyze_colvars`. It needs
20 | #' [summarize_patients_exposure_in_cols()] to leverage nesting of label rows analysis
21 | #' with [rtables::summarize_row_groups()].
22 | #' * [summarize_coxreg()]: generally based on [rtables::summarize_row_groups()], it behaves
23 | #' similarly to `tabulate_*` functions described above as it is designed to provide
24 | #' specific standard tables that may contain nested structure with a combination of
25 | #' `summarize_row_groups()` and [rtables::analyze_colvars()].
26 | #'
27 | #' @seealso
28 | #' * [summarize_functions] for functions which are wrappers for [rtables::summarize_row_groups()].
29 | #' * [analyze_functions] for functions which are wrappers for [rtables::analyze()].
30 | #'
31 | #' @name analyze_colvars_functions
32 | NULL
33 |
--------------------------------------------------------------------------------
/R/analyze_functions.R:
--------------------------------------------------------------------------------
1 | #' Analyze functions
2 | #'
3 | #' @description
4 | #'
5 | #' These functions are wrappers of [rtables::analyze()] which apply corresponding `tern` statistics functions
6 | #' to add an analysis to a given table layout:
7 | #'
8 | #' * [analyze_num_patients()]
9 | #' * [analyze_vars()]
10 | #' * [compare_vars()]
11 | #' * [count_abnormal()]
12 | #' * [count_abnormal_by_baseline()]
13 | #' * [count_abnormal_by_marked()]
14 | #' * [count_abnormal_by_worst_grade()]
15 | #' * [count_cumulative()]
16 | #' * [count_missed_doses()]
17 | #' * [count_occurrences()]
18 | #' * [count_occurrences_by_grade()]
19 | #' * [count_patients_events_in_cols()]
20 | #' * [count_patients_with_event()]
21 | #' * [count_patients_with_flags()]
22 | #' * [count_values()]
23 | #' * [coxph_pairwise()]
24 | #' * [estimate_incidence_rate()]
25 | #' * [estimate_multinomial_rsp()]
26 | #' * [estimate_odds_ratio()]
27 | #' * [estimate_proportion()]
28 | #' * [estimate_proportion_diff()]
29 | #' * [summarize_ancova()]
30 | #' * [summarize_colvars()]: even if this function uses [rtables::analyze_colvars()],
31 | #' it applies the analysis methods as different rows for one or more
32 | #' variables that are split into different columns. In comparison, [analyze_colvars_functions]
33 | #' leverage `analyze_colvars` to have the context split in rows and the analysis
34 | #' methods in columns.
35 | #' * [summarize_change()]
36 | #' * [surv_time()]
37 | #' * [surv_timepoint()]
38 | #' * [test_proportion_diff()]
39 | #'
40 | #' @seealso
41 | #' * [analyze_colvars_functions] for functions that are wrappers for [rtables::analyze_colvars()].
42 | #' * [summarize_functions] for functions which are wrappers for [rtables::summarize_row_groups()].
43 | #'
44 | #' @name analyze_functions
45 | NULL
46 |
--------------------------------------------------------------------------------
/R/control_incidence_rate.R:
--------------------------------------------------------------------------------
1 | #' Control function for incidence rate
2 | #'
3 | #' @description `r lifecycle::badge("stable")`
4 | #'
5 | #' This is an auxiliary function for controlling arguments for the incidence rate, used
6 | #' internally to specify details in `s_incidence_rate()`.
7 | #'
8 | #' @inheritParams argument_convention
9 | #' @param conf_type (`string`)\cr `normal` (default), `normal_log`, `exact`, or `byar`
10 | #' for confidence interval type.
11 | #' @param input_time_unit (`string`)\cr `day`, `week`, `month`, or `year` (default)
12 | #' indicating time unit for data input.
13 | #' @param num_pt_year (`numeric(1)`)\cr number of patient-years to use when calculating adverse event rates.
14 | #'
15 | #' @return A list of components with the same names as the arguments.
16 | #'
17 | #' @seealso [incidence_rate]
18 | #'
19 | #' @examples
20 | #' control_incidence_rate(0.9, "exact", "month", 100)
21 | #'
22 | #' @export
23 | control_incidence_rate <- function(conf_level = 0.95,
24 | conf_type = c("normal", "normal_log", "exact", "byar"),
25 | input_time_unit = c("year", "day", "week", "month"),
26 | num_pt_year = 100) {
27 | conf_type <- match.arg(conf_type)
28 | input_time_unit <- match.arg(input_time_unit)
29 | checkmate::assert_number(num_pt_year)
30 | assert_proportion_value(conf_level)
31 |
32 | list(
33 | conf_level = conf_level,
34 | conf_type = conf_type,
35 | input_time_unit = input_time_unit,
36 | num_pt_year = num_pt_year
37 | )
38 | }
39 |
--------------------------------------------------------------------------------
/R/control_logistic.R:
--------------------------------------------------------------------------------
1 | #' Control function for logistic regression model fitting
2 | #'
3 | #' @description `r lifecycle::badge("stable")`
4 | #'
5 | #' This is an auxiliary function for controlling arguments for logistic regression models.
6 | #' `conf_level` refers to the confidence level used for the Odds Ratio CIs.
7 | #'
8 | #' @inheritParams argument_convention
9 | #' @param response_definition (`string`)\cr the definition of what an event is in terms of `response`.
10 | #' This will be used when fitting the logistic regression model on the left hand side of the formula.
11 | #' Note that the evaluated expression should result in either a logical vector or a factor with 2
12 | #' levels. By default this is just `"response"` such that the original response variable is used
13 | #' and not modified further.
14 | #'
15 | #' @return A list of components with the same names as the arguments.
16 | #'
17 | #' @examples
18 | #' # Standard options.
19 | #' control_logistic()
20 | #'
21 | #' # Modify confidence level.
22 | #' control_logistic(conf_level = 0.9)
23 | #'
24 | #' # Use a different response definition.
25 | #' control_logistic(response_definition = "I(response %in% c('CR', 'PR'))")
26 | #'
27 | #' @export
28 | control_logistic <- function(response_definition = "response",
29 | conf_level = 0.95) {
30 | checkmate::assert_true(grepl("response", response_definition))
31 | checkmate::assert_string(response_definition)
32 | assert_proportion_value(conf_level)
33 | list(
34 | response_definition = response_definition,
35 | conf_level = conf_level
36 | )
37 | }
38 |
--------------------------------------------------------------------------------
/R/data.R:
--------------------------------------------------------------------------------
1 | #' Simulated CDISC data for examples
2 | #'
3 | #' @format `rds` (`data.frame`)
4 | #'
5 | #' @name ex_data
6 | NULL
7 |
8 | #' @describeIn ex_data ADSL data
9 | #'
10 | "tern_ex_adsl"
11 |
12 | #' @describeIn ex_data ADAE data
13 | #'
14 | "tern_ex_adae"
15 |
16 | #' @describeIn ex_data ADLB data
17 | #'
18 | "tern_ex_adlb"
19 |
20 | #' @describeIn ex_data ADPP data
21 | #'
22 | "tern_ex_adpp"
23 |
24 | #' @describeIn ex_data ADRS data
25 | #'
26 | "tern_ex_adrs"
27 |
28 | #' @describeIn ex_data ADTTE data
29 | #'
30 | "tern_ex_adtte"
31 |
--------------------------------------------------------------------------------
/R/h_pkparam_sort.R:
--------------------------------------------------------------------------------
1 | #' Sort pharmacokinetic data by `PARAM` variable
2 | #'
3 | #' @description `r lifecycle::badge("stable")`
4 | #'
5 | #' @param pk_data (`data.frame`)\cr pharmacokinetic data frame.
6 | #' @param key_var (`string`)\cr key variable used to merge pk_data and metadata created by [d_pkparam()].
7 | #'
8 | #' @return A pharmacokinetic `data.frame` sorted by a `PARAM` variable.
9 | #'
10 | #' @examples
11 | #' library(dplyr)
12 | #'
13 | #' adpp <- tern_ex_adpp %>% mutate(PKPARAM = factor(paste0(PARAM, " (", AVALU, ")")))
14 | #' pk_ordered_data <- h_pkparam_sort(adpp)
15 | #'
16 | #' @export
17 | h_pkparam_sort <- function(pk_data, key_var = "PARAMCD") {
18 | assert_df_with_variables(pk_data, list(key_var = key_var))
19 | pk_data$PARAMCD <- pk_data[[key_var]]
20 |
21 | ordered_pk_data <- d_pkparam()
22 |
23 | # Add the numeric values from ordered_pk_data to pk_data
24 | joined_data <- merge(pk_data, ordered_pk_data, by = "PARAMCD", suffixes = c("", ".y"))
25 |
26 | joined_data <- joined_data[, -grep(".*.y$", colnames(joined_data))]
27 |
28 | joined_data$TLG_ORDER <- as.numeric(joined_data$TLG_ORDER)
29 |
30 | # Then order PARAM based on this column
31 | joined_data$PARAM <- factor(joined_data$PARAM,
32 | levels = unique(joined_data$PARAM[order(joined_data$TLG_ORDER)]),
33 | ordered = TRUE
34 | )
35 |
36 | joined_data$TLG_DISPLAY <- factor(joined_data$TLG_DISPLAY,
37 | levels = unique(joined_data$TLG_DISPLAY[order(joined_data$TLG_ORDER)]),
38 | ordered = TRUE
39 | )
40 |
41 | joined_data
42 | }
43 |
--------------------------------------------------------------------------------
/R/package.R:
--------------------------------------------------------------------------------
1 | #' tern Package
2 | #'
3 | #' Package to create tables, listings and graphs to analyze clinical trials data.
4 | #'
5 | "_PACKAGE"
6 |
7 | #' @import rtables ggplot2
8 | #' @importFrom broom tidy
9 | #' @importFrom formatters format_value propose_column_widths
10 | #' @importFrom magrittr %>%
11 | #' @importFrom methods new
12 | #' @importFrom nestcolor theme_nest
13 | #' @importFrom Rdpack reprompt
14 | #' @importFrom rlang .data %||%
15 | #' @importFrom survival coxph strata Surv
16 | #' @importFrom stats pchisq setNames complete.cases qnorm qt sd
17 | NULL
18 |
19 | # Resolve missing global definitions:
20 | utils::globalVariables(c(
21 | ".",
22 | ".all_col_counts",
23 | ".df_row",
24 | ".N_col",
25 | ".N_row",
26 | ".spl_context",
27 | ".var",
28 | "x",
29 | "average",
30 | "difference",
31 | "control_coxph",
32 | "control_incidence_rate",
33 | "control_analyze_vars",
34 | "control_surv_time",
35 | "control_surv_timepoint"
36 | ))
37 |
--------------------------------------------------------------------------------
/R/summarize_functions.R:
--------------------------------------------------------------------------------
1 | #' Summarize functions
2 | #'
3 | #' These functions are wrappers for [`rtables::summarize_row_groups()`], applying corresponding `tern` content functions
4 | #' to add summary rows to a given table layout:
5 | #'
6 | #' * [add_rowcounts()]
7 | #' * [estimate_multinomial_response()] (with [rtables::analyze()])
8 | #' * [logistic_summary_by_flag()]
9 | #' * [summarize_num_patients()]
10 | #' * [summarize_occurrences()]
11 | #' * [summarize_occurrences_by_grade()]
12 | #' * [summarize_patients_events_in_cols()]
13 | #' * [summarize_patients_exposure_in_cols()]
14 | #'
15 | #' Additionally, the [summarize_coxreg()] function utilizes [`rtables::summarize_row_groups()`]
16 | #' (in combination with several other `rtables` functions like [rtables::analyze_colvars()]) to
17 | #' output a Cox regression summary table.
18 | #'
19 | #' @seealso
20 | #' * [analyze_functions] for functions which are wrappers for [rtables::analyze()].
21 | #' * [analyze_colvars_functions] for functions that are wrappers for [rtables::analyze_colvars()].
22 | #'
23 | #' @name summarize_functions
24 | NULL
25 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Reporting Security Issues
4 |
5 | If you believe you have found a security vulnerability in any of the repositories in this organization, please report it to us through coordinated disclosure.
6 |
7 | **Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
8 |
9 | Instead, please send an email to vulnerability.management[@]roche.com.
10 |
11 | Please include as much of the information listed below as you can to help us better understand and resolve the issue:
12 |
13 | * The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
14 | * Full paths of source file(s) related to the manifestation of the issue
15 | * The location of the affected source code (tag/branch/commit or direct URL)
16 | * Any special configuration required to reproduce the issue
17 | * Step-by-step instructions to reproduce the issue
18 | * Proof-of-concept or exploit code (if possible)
19 | * Impact of the issue, including how an attacker might exploit the issue
20 |
21 | This information will help us triage your report more quickly.
22 |
23 | ## Data Security Standards (DSS)
24 |
25 | Please make sure that while reporting issues in the form a bug, feature, or pull request, *all* sensitive information such as [PII](https://www.dhs.gov/privacy-training/what-personally-identifiable-information), [PHI](https://www.hhs.gov/hipaa/for-professionals/security/laws-regulations/index.html), and [PCI](https://www.pcisecuritystandards.org/pci_security/standards_overview) is completely removed from any text and attachments, including pictures and videos.
26 |
--------------------------------------------------------------------------------
/data/tern_ex_adae.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/data/tern_ex_adae.rda
--------------------------------------------------------------------------------
/data/tern_ex_adlb.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/data/tern_ex_adlb.rda
--------------------------------------------------------------------------------
/data/tern_ex_adpp.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/data/tern_ex_adpp.rda
--------------------------------------------------------------------------------
/data/tern_ex_adrs.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/data/tern_ex_adrs.rda
--------------------------------------------------------------------------------
/data/tern_ex_adsl.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/data/tern_ex_adsl.rda
--------------------------------------------------------------------------------
/data/tern_ex_adtte.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/data/tern_ex_adtte.rda
--------------------------------------------------------------------------------
/inst/WORDLIST:
--------------------------------------------------------------------------------
1 | ADAE
2 | ADLB
3 | ADPP
4 | ADRS
5 | ADSL
6 | ADTTE
7 | AE
8 | ANCOVA
9 | Agresti
10 | Bové
11 | Byar's
12 | CDISC
13 | CMH
14 | CQ
15 | Clopper
16 | Coull
17 | Forkers
18 | Haenszel
19 | Hauck
20 | Hoffmann
21 | Jeffreys
22 | Kaplan
23 | Kenward
24 | MMRM
25 | MedDRA
26 | Newcombe
27 | ORCID
28 | Pre
29 | Rua
30 | SMQ
31 | Sabanés
32 | Satterthwaite
33 | Schouten
34 | TLG
35 | TLGs
36 | biomarker
37 | biomarkers
38 | de
39 | funder
40 | layouting
41 | pharmacokinetic
42 | pre
43 | responder
44 | responders
45 | subtable
46 | subtables
47 | unformatted
48 | ungroup
49 | unstratified
50 |
--------------------------------------------------------------------------------
/man/add_rowcounts.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{add_rowcounts}
4 | \alias{add_rowcounts}
5 | \title{Layout-creating function to add row total counts}
6 | \usage{
7 | add_rowcounts(lyt, alt_counts = FALSE)
8 | }
9 | \arguments{
10 | \item{lyt}{(\code{PreDataTableLayouts})\cr layout that analyses will be added to.}
11 |
12 | \item{alt_counts}{(\code{flag})\cr whether row counts should be taken from \code{alt_counts_df} (\code{TRUE})
13 | or from \code{df} (\code{FALSE}). Defaults to \code{FALSE}.}
14 | }
15 | \value{
16 | A modified layout where the latest row split labels now have the row-wise
17 | total counts (i.e. without column-based subsetting) attached in parentheses.
18 | }
19 | \description{
20 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
21 |
22 | This works analogously to \code{\link[rtables:add_colcounts]{rtables::add_colcounts()}} but on the rows. This function
23 | is a wrapper for \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}}.
24 | }
25 | \note{
26 | Row count values are contained in these row count rows but are not displayed
27 | so that they are not considered zero rows by default when pruning.
28 | }
29 | \examples{
30 | basic_table() \%>\%
31 | split_cols_by("ARM") \%>\%
32 | add_colcounts() \%>\%
33 | split_rows_by("RACE", split_fun = drop_split_levels) \%>\%
34 | add_rowcounts() \%>\%
35 | analyze("AGE", afun = list_wrap_x(summary), format = "xx.xx") \%>\%
36 | build_table(DM)
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/man/aesi_label.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{aesi_label}
4 | \alias{aesi_label}
5 | \title{Labels for adverse event baskets}
6 | \usage{
7 | aesi_label(aesi, scope = NULL)
8 | }
9 | \arguments{
10 | \item{aesi}{(\code{character})\cr vector with standardized MedDRA query name (e.g. \code{SMQxxNAM}) or customized query
11 | name (e.g. \code{CQxxNAM}).}
12 |
13 | \item{scope}{(\code{character})\cr vector with scope of query (e.g. \code{SMQxxSC}).}
14 | }
15 | \value{
16 | A \code{string} with the standard label for the AE basket.
17 | }
18 | \description{
19 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
20 | }
21 | \examples{
22 | adae <- tern_ex_adae
23 |
24 | # Standardized query label includes scope.
25 | aesi_label(adae$SMQ01NAM, scope = adae$SMQ01SC)
26 |
27 | # Customized query label.
28 | aesi_label(adae$CQ01NAM)
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/man/afun_selected_stats.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{afun_selected_stats}
4 | \alias{afun_selected_stats}
5 | \title{Get selected statistics names}
6 | \usage{
7 | afun_selected_stats(.stats, all_stats)
8 | }
9 | \arguments{
10 | \item{.stats}{(\code{vector} or \code{NULL})\cr input to the layout creating function. Note that \code{NULL} means
11 | in this context that all default statistics should be used.}
12 |
13 | \item{all_stats}{(\code{character})\cr all statistics which can be selected here potentially.}
14 | }
15 | \value{
16 | A \code{character} vector with the selected statistics.
17 | }
18 | \description{
19 | Helper function to be used for creating \code{afun}.
20 | }
21 | \keyword{internal}
22 |
--------------------------------------------------------------------------------
/man/apply_auto_formatting.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{apply_auto_formatting}
4 | \alias{apply_auto_formatting}
5 | \title{Apply automatic formatting}
6 | \usage{
7 | apply_auto_formatting(.formats, x_stats, .df_row, .var)
8 | }
9 | \arguments{
10 | \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more
11 | information on the \code{"auto"} setting.}
12 |
13 | \item{x_stats}{(named \code{list})\cr a named list of statistics where each element corresponds
14 | to an element in \code{.formats}, with matching names.}
15 |
16 | \item{.df_row}{(\code{data.frame})\cr data frame across all of the columns for the given row split.}
17 |
18 | \item{.var}{(\code{string})\cr single variable name that is passed by \code{rtables} when requested
19 | by a statistics function.}
20 | }
21 | \description{
22 | Checks if any of the listed formats in \code{.formats} are \code{"auto"}, and replaces \code{"auto"} with
23 | the correct implementation of \code{format_auto} for the given statistics, data, and variable.
24 | }
25 | \keyword{internal}
26 |
--------------------------------------------------------------------------------
/man/as.rtable.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{as.rtable}
4 | \alias{as.rtable}
5 | \alias{as.rtable.data.frame}
6 | \title{Convert to \code{rtable}}
7 | \usage{
8 | as.rtable(x, ...)
9 |
10 | \method{as.rtable}{data.frame}(x, format = "xx.xx", ...)
11 | }
12 | \arguments{
13 | \item{x}{(\code{data.frame})\cr the object which should be converted to an \code{rtable}.}
14 |
15 | \item{...}{additional arguments for methods.}
16 |
17 | \item{format}{(\code{string} or \code{function})\cr the format which should be used for the columns.}
18 | }
19 | \value{
20 | An \code{rtables} table object. Note that the concrete class will depend on the method used.
21 | }
22 | \description{
23 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
24 |
25 | This is a new generic function to convert objects to \code{rtable} tables.
26 | }
27 | \section{Methods (by class)}{
28 | \itemize{
29 | \item \code{as.rtable(data.frame)}: Method for converting a \code{data.frame} that contains numeric columns to \code{rtable}.
30 |
31 | }}
32 | \examples{
33 | x <- data.frame(
34 | a = 1:10,
35 | b = rnorm(10)
36 | )
37 | as.rtable(x)
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/man/bins_percent_labels.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_factor.R
3 | \name{bins_percent_labels}
4 | \alias{bins_percent_labels}
5 | \title{Labels for bins in percent}
6 | \usage{
7 | bins_percent_labels(probs, digits = 0)
8 | }
9 | \arguments{
10 | \item{probs}{(\code{numeric})\cr the probabilities identifying the quantiles.
11 | This is a sorted vector of unique \code{proportion} values, i.e. between 0 and 1, where
12 | the boundaries 0 and 1 must not be included.}
13 |
14 | \item{digits}{(\code{integer(1)})\cr number of decimal places to round the percent numbers.}
15 | }
16 | \value{
17 | A \code{character} vector with labels in the format \verb{[0\%,20\%]}, \verb{(20\%,50\%]}, etc.
18 | }
19 | \description{
20 | This creates labels for quantile based bins in percent. This assumes the right-closed
21 | intervals as produced by \code{\link[=cut_quantile_bins]{cut_quantile_bins()}}.
22 | }
23 | \keyword{internal}
24 |
--------------------------------------------------------------------------------
/man/c_label_n.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{c_label_n}
4 | \alias{c_label_n}
5 | \title{Content row function to add row total to labels}
6 | \usage{
7 | c_label_n(df, labelstr, .N_row)
8 | }
9 | \arguments{
10 | \item{df}{(\code{data.frame})\cr data set containing all analysis variables.}
11 |
12 | \item{labelstr}{(\code{string})\cr label of the level of the parent split currently being summarized
13 | (must be present as second argument in Content Row Functions). See \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}}
14 | for more information.}
15 |
16 | \item{.N_row}{(\code{integer(1)})\cr row-wise N (row group count) for the group of observations being analyzed
17 | (i.e. with no column-based subsetting) that is typically passed by \code{rtables}.}
18 | }
19 | \value{
20 | A list with formatted \code{\link[rtables:CellValue]{rtables::CellValue()}} with the row count value and the correct label.
21 | }
22 | \description{
23 | This takes the label of the latest row split level and adds the row total from \code{df} in parentheses.
24 | This function differs from \code{\link[=c_label_n_alt]{c_label_n_alt()}} by taking row counts from \code{df} rather than
25 | \code{alt_counts_df}, and is used by \code{\link[=add_rowcounts]{add_rowcounts()}} when \code{alt_counts} is set to \code{FALSE}.
26 | }
27 | \note{
28 | It is important here to not use \code{df} but rather \code{.N_row} in the implementation, because
29 | the former is already split by columns and will refer to the first column of the data only.
30 | }
31 | \seealso{
32 | \code{\link[=c_label_n_alt]{c_label_n_alt()}} which performs the same function but retrieves row counts from
33 | \code{alt_counts_df} instead of \code{df}.
34 | }
35 | \keyword{internal}
36 |
--------------------------------------------------------------------------------
/man/c_label_n_alt.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{c_label_n_alt}
4 | \alias{c_label_n_alt}
5 | \title{Content row function to add \code{alt_counts_df} row total to labels}
6 | \usage{
7 | c_label_n_alt(df, labelstr, .alt_df_row)
8 | }
9 | \arguments{
10 | \item{df}{(\code{data.frame})\cr data set containing all analysis variables.}
11 |
12 | \item{labelstr}{(\code{string})\cr label of the level of the parent split currently being summarized
13 | (must be present as second argument in Content Row Functions). See \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}}
14 | for more information.}
15 | }
16 | \value{
17 | A list with formatted \code{\link[rtables:CellValue]{rtables::CellValue()}} with the row count value and the correct label.
18 | }
19 | \description{
20 | This takes the label of the latest row split level and adds the row total from \code{alt_counts_df}
21 | in parentheses. This function differs from \code{\link[=c_label_n]{c_label_n()}} by taking row counts from \code{alt_counts_df}
22 | rather than \code{df}, and is used by \code{\link[=add_rowcounts]{add_rowcounts()}} when \code{alt_counts} is set to \code{TRUE}.
23 | }
24 | \seealso{
25 | \code{\link[=c_label_n]{c_label_n()}} which performs the same function but retrieves row counts from \code{df} instead
26 | of \code{alt_counts_df}.
27 | }
28 | \keyword{internal}
29 |
--------------------------------------------------------------------------------
/man/cfun_by_flag.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{cfun_by_flag}
4 | \alias{cfun_by_flag}
5 | \title{Constructor for content functions given a data frame with flag input}
6 | \usage{
7 | cfun_by_flag(analysis_var, flag_var, format = "xx", .indent_mods = NULL)
8 | }
9 | \arguments{
10 | \item{analysis_var}{(\code{string})\cr variable name for the column containing values to be returned by the
11 | content function.}
12 |
13 | \item{flag_var}{(\code{string})\cr variable name for the logical column identifying which row should be returned.}
14 |
15 | \item{format}{(\code{string})\cr \code{rtables} format to use.}
16 | }
17 | \value{
18 | A content function which gives \code{df$analysis_var} at the row identified by
19 | \code{.df_row$flag} in the given format.
20 | }
21 | \description{
22 | This can be useful for tabulating model results.
23 | }
24 | \keyword{internal}
25 |
--------------------------------------------------------------------------------
/man/check_diff_prop_ci.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prop_diff.R
3 | \name{check_diff_prop_ci}
4 | \alias{check_diff_prop_ci}
5 | \title{Check proportion difference arguments}
6 | \usage{
7 | check_diff_prop_ci(rsp, grp, strata = NULL, conf_level, correct = NULL)
8 | }
9 | \arguments{
10 | \item{rsp}{(\code{logical})\cr vector indicating whether each subject is a responder or not.}
11 |
12 | \item{grp}{(\code{factor})\cr vector assigning observations to one out of two groups
13 | (e.g. reference and treatment group).}
14 |
15 | \item{strata}{(\code{factor})\cr variable with one level per stratum and same length as \code{rsp}.}
16 |
17 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
18 |
19 | \item{correct}{(\code{flag})\cr whether to include the continuity correction. For further
20 | information, see \code{\link[stats:prop.test]{stats::prop.test()}}.}
21 | }
22 | \description{
23 | Verifies that and/or convert arguments into valid values to be used in the
24 | estimation of difference in responder proportions.
25 | }
26 | \keyword{internal}
27 |
--------------------------------------------------------------------------------
/man/check_same_n.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{check_same_n}
4 | \alias{check_same_n}
5 | \title{Check element dimension}
6 | \usage{
7 | check_same_n(..., omit_null = TRUE)
8 | }
9 | \arguments{
10 | \item{...}{(\code{data.frame} or \code{vector})\cr any data frames or vectors.}
11 |
12 | \item{omit_null}{(\code{flag})\cr whether \code{NULL} elements in \code{...} should be omitted from the check.}
13 | }
14 | \value{
15 | A \code{logical} value.
16 | }
17 | \description{
18 | Checks if the elements in \code{...} have the same dimension.
19 | }
20 | \keyword{internal}
21 |
--------------------------------------------------------------------------------
/man/combine_counts.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/split_cols_by_groups.R
3 | \name{combine_counts}
4 | \alias{combine_counts}
5 | \title{Combine counts}
6 | \usage{
7 | combine_counts(fct, groups_list = NULL)
8 | }
9 | \arguments{
10 | \item{fct}{(\code{factor})\cr the variable with levels which needs to be grouped.}
11 |
12 | \item{groups_list}{(named \code{list} of \code{character})\cr specifies the new group levels via the names and the
13 | levels that belong to it in the character vectors that are elements of the list.}
14 | }
15 | \value{
16 | A \code{vector} of column counts.
17 | }
18 | \description{
19 | Simplifies the estimation of column counts, especially when group combination is required.
20 | }
21 | \examples{
22 | ref <- c("A: Drug X", "B: Placebo")
23 | groups <- combine_groups(fct = DM$ARM, ref = ref)
24 |
25 | col_counts <- combine_counts(
26 | fct = DM$ARM,
27 | groups_list = groups
28 | )
29 |
30 | basic_table() \%>\%
31 | split_cols_by_groups("ARM", groups) \%>\%
32 | add_colcounts() \%>\%
33 | analyze_vars("AGE") \%>\%
34 | build_table(DM, col_counts = col_counts)
35 |
36 | ref <- "A: Drug X"
37 | groups <- combine_groups(fct = DM$ARM, ref = ref)
38 | col_counts <- combine_counts(
39 | fct = DM$ARM,
40 | groups_list = groups
41 | )
42 |
43 | basic_table() \%>\%
44 | split_cols_by_groups("ARM", groups) \%>\%
45 | add_colcounts() \%>\%
46 | analyze_vars("AGE") \%>\%
47 | build_table(DM, col_counts = col_counts)
48 |
49 | }
50 | \seealso{
51 | \code{\link[=combine_groups]{combine_groups()}}
52 | }
53 |
--------------------------------------------------------------------------------
/man/combine_groups.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/split_cols_by_groups.R
3 | \name{combine_groups}
4 | \alias{combine_groups}
5 | \title{Reference and treatment group combination}
6 | \usage{
7 | combine_groups(fct, ref = NULL, collapse = "/")
8 | }
9 | \arguments{
10 | \item{fct}{(\code{factor})\cr the variable with levels which needs to be grouped.}
11 |
12 | \item{ref}{(\code{character})\cr the reference level(s).}
13 |
14 | \item{collapse}{(\code{string})\cr a character string to separate \code{fct} and \code{ref}.}
15 | }
16 | \value{
17 | A \code{list} with first item \code{ref} (reference) and second item \code{trt} (treatment).
18 | }
19 | \description{
20 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
21 |
22 | Facilitate the re-combination of groups divided as reference and treatment groups; it helps in arranging groups of
23 | columns in the \code{rtables} framework and teal modules.
24 | }
25 | \examples{
26 | groups <- combine_groups(
27 | fct = DM$ARM,
28 | ref = c("B: Placebo")
29 | )
30 |
31 | basic_table() \%>\%
32 | split_cols_by_groups("ARM", groups) \%>\%
33 | add_colcounts() \%>\%
34 | analyze_vars("AGE") \%>\%
35 | build_table(DM)
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/man/combine_vectors.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{combine_vectors}
4 | \alias{combine_vectors}
5 | \title{Element-wise combination of two vectors}
6 | \usage{
7 | combine_vectors(x, y)
8 | }
9 | \arguments{
10 | \item{x}{(\code{vector})\cr first vector to combine.}
11 |
12 | \item{y}{(\code{vector})\cr second vector to combine.}
13 | }
14 | \value{
15 | A \code{list} where each element combines corresponding elements of \code{x} and \code{y}.
16 | }
17 | \description{
18 | Element-wise combination of two vectors
19 | }
20 | \examples{
21 | combine_vectors(1:3, 4:6)
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/man/control_analyze_vars.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/analyze_variables.R
3 | \name{control_analyze_vars}
4 | \alias{control_analyze_vars}
5 | \title{Control function for descriptive statistics}
6 | \usage{
7 | control_analyze_vars(
8 | conf_level = 0.95,
9 | quantiles = c(0.25, 0.75),
10 | quantile_type = 2,
11 | test_mean = 0
12 | )
13 | }
14 | \arguments{
15 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
16 |
17 | \item{quantiles}{(\code{numeric(2)})\cr vector of length two to specify the quantiles to calculate.}
18 |
19 | \item{quantile_type}{(\code{numeric(1)})\cr number between 1 and 9 selecting quantile algorithms to be used.
20 | Default is set to 2 as this matches the default quantile algorithm in SAS \verb{proc univariate} set by \code{QNTLDEF=5}.
21 | This differs from R's default. See more about \code{type} in \code{\link[stats:quantile]{stats::quantile()}}.}
22 |
23 | \item{test_mean}{(\code{numeric(1)})\cr number to test against the mean under the null hypothesis when calculating
24 | p-value.}
25 | }
26 | \value{
27 | A list of components with the same names as the arguments.
28 | }
29 | \description{
30 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
31 |
32 | Sets a list of parameters for summaries of descriptive statistics. Typically used internally to specify
33 | details for \code{\link[=s_summary]{s_summary()}}. This function family is mainly used by \code{\link[=analyze_vars]{analyze_vars()}}.
34 | }
35 |
--------------------------------------------------------------------------------
/man/control_coxph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/control_survival.R
3 | \name{control_coxph}
4 | \alias{control_coxph}
5 | \title{Control function for Cox-PH model}
6 | \usage{
7 | control_coxph(
8 | pval_method = c("log-rank", "wald", "likelihood"),
9 | ties = c("efron", "breslow", "exact"),
10 | conf_level = 0.95
11 | )
12 | }
13 | \arguments{
14 | \item{pval_method}{(\code{string})\cr p-value method for testing hazard ratio = 1.
15 | Default method is \code{"log-rank"}, can also be set to \code{"wald"} or \code{"likelihood"}.}
16 |
17 | \item{ties}{(\code{string})\cr string specifying the method for tie handling. Default is \code{"efron"},
18 | can also be set to \code{"breslow"} or \code{"exact"}. See more in \code{\link[survival:coxph]{survival::coxph()}}.}
19 |
20 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
21 | }
22 | \value{
23 | A list of components with the same names as the arguments.
24 | }
25 | \description{
26 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
27 |
28 | This is an auxiliary function for controlling arguments for Cox-PH model, typically used internally to specify
29 | details of Cox-PH model for \code{\link[=s_coxph_pairwise]{s_coxph_pairwise()}}. \code{conf_level} refers to Hazard Ratio estimation.
30 | }
31 |
--------------------------------------------------------------------------------
/man/control_coxreg.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/cox_regression.R
3 | \name{control_coxreg}
4 | \alias{control_coxreg}
5 | \title{Control function for Cox regression}
6 | \usage{
7 | control_coxreg(
8 | pval_method = c("wald", "likelihood"),
9 | ties = c("exact", "efron", "breslow"),
10 | conf_level = 0.95,
11 | interaction = FALSE
12 | )
13 | }
14 | \arguments{
15 | \item{pval_method}{(\code{string})\cr the method used for estimation of p.values; \code{wald} (default) or \code{likelihood}.}
16 |
17 | \item{ties}{(\code{string})\cr among \code{exact} (equivalent to \code{DISCRETE} in SAS), \code{efron} and \code{breslow},
18 | see \code{\link[survival:coxph]{survival::coxph()}}. Note: there is no equivalent of SAS \code{EXACT} method in R.}
19 |
20 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
21 |
22 | \item{interaction}{(\code{flag})\cr if \code{TRUE}, the model includes the interaction between the studied
23 | treatment and candidate covariate. Note that for univariate models without treatment arm, and
24 | multivariate models, no interaction can be used so that this needs to be \code{FALSE}.}
25 | }
26 | \value{
27 | A \code{list} of items with names corresponding to the arguments.
28 | }
29 | \description{
30 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
31 |
32 | Sets a list of parameters for Cox regression fit. Used internally.
33 | }
34 | \examples{
35 | control_coxreg()
36 |
37 | }
38 | \seealso{
39 | \code{\link[=fit_coxreg_univar]{fit_coxreg_univar()}} and \code{\link[=fit_coxreg_multivar]{fit_coxreg_multivar()}}.
40 | }
41 |
--------------------------------------------------------------------------------
/man/control_incidence_rate.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/control_incidence_rate.R
3 | \name{control_incidence_rate}
4 | \alias{control_incidence_rate}
5 | \title{Control function for incidence rate}
6 | \usage{
7 | control_incidence_rate(
8 | conf_level = 0.95,
9 | conf_type = c("normal", "normal_log", "exact", "byar"),
10 | input_time_unit = c("year", "day", "week", "month"),
11 | num_pt_year = 100
12 | )
13 | }
14 | \arguments{
15 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
16 |
17 | \item{conf_type}{(\code{string})\cr \code{normal} (default), \code{normal_log}, \code{exact}, or \code{byar}
18 | for confidence interval type.}
19 |
20 | \item{input_time_unit}{(\code{string})\cr \code{day}, \code{week}, \code{month}, or \code{year} (default)
21 | indicating time unit for data input.}
22 |
23 | \item{num_pt_year}{(\code{numeric(1)})\cr number of patient-years to use when calculating adverse event rates.}
24 | }
25 | \value{
26 | A list of components with the same names as the arguments.
27 | }
28 | \description{
29 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
30 |
31 | This is an auxiliary function for controlling arguments for the incidence rate, used
32 | internally to specify details in \code{s_incidence_rate()}.
33 | }
34 | \examples{
35 | control_incidence_rate(0.9, "exact", "month", 100)
36 |
37 | }
38 | \seealso{
39 | \link{incidence_rate}
40 | }
41 |
--------------------------------------------------------------------------------
/man/control_lineplot_vars.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/g_lineplot.R
3 | \name{control_lineplot_vars}
4 | \alias{control_lineplot_vars}
5 | \title{Control function for \code{g_lineplot()}}
6 | \usage{
7 | control_lineplot_vars(
8 | x = "AVISIT",
9 | y = "AVAL",
10 | group_var = "ARM",
11 | facet_var = NA,
12 | paramcd = "PARAMCD",
13 | y_unit = "AVALU",
14 | subject_var = "USUBJID"
15 | )
16 | }
17 | \arguments{
18 | \item{x}{(\code{string})\cr x-variable name.}
19 |
20 | \item{y}{(\code{string})\cr y-variable name.}
21 |
22 | \item{group_var}{(\code{string} or \code{NA})\cr group variable name.}
23 |
24 | \item{facet_var}{(\code{string} or \code{NA})\cr faceting variable name.}
25 |
26 | \item{paramcd}{(\code{string} or \code{NA})\cr parameter code variable name.}
27 |
28 | \item{y_unit}{(\code{string} or \code{NA})\cr y-axis unit variable name.}
29 |
30 | \item{subject_var}{(\code{string} or \code{NA})\cr subject variable name.}
31 | }
32 | \value{
33 | A named character vector of variable names.
34 | }
35 | \description{
36 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
37 |
38 | Default values for \code{variables} parameter in \code{g_lineplot} function.
39 | A variable's default value can be overwritten for any variable.
40 | }
41 | \examples{
42 | control_lineplot_vars()
43 | control_lineplot_vars(group_var = NA)
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/man/control_logistic.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/control_logistic.R
3 | \name{control_logistic}
4 | \alias{control_logistic}
5 | \title{Control function for logistic regression model fitting}
6 | \usage{
7 | control_logistic(response_definition = "response", conf_level = 0.95)
8 | }
9 | \arguments{
10 | \item{response_definition}{(\code{string})\cr the definition of what an event is in terms of \code{response}.
11 | This will be used when fitting the logistic regression model on the left hand side of the formula.
12 | Note that the evaluated expression should result in either a logical vector or a factor with 2
13 | levels. By default this is just \code{"response"} such that the original response variable is used
14 | and not modified further.}
15 |
16 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
17 | }
18 | \value{
19 | A list of components with the same names as the arguments.
20 | }
21 | \description{
22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
23 |
24 | This is an auxiliary function for controlling arguments for logistic regression models.
25 | \code{conf_level} refers to the confidence level used for the Odds Ratio CIs.
26 | }
27 | \examples{
28 | # Standard options.
29 | control_logistic()
30 |
31 | # Modify confidence level.
32 | control_logistic(conf_level = 0.9)
33 |
34 | # Use a different response definition.
35 | control_logistic(response_definition = "I(response \%in\% c('CR', 'PR'))")
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/man/control_surv_time.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/control_survival.R
3 | \name{control_surv_time}
4 | \alias{control_surv_time}
5 | \title{Control function for \code{survfit} models for survival time}
6 | \usage{
7 | control_surv_time(
8 | conf_level = 0.95,
9 | conf_type = c("plain", "log", "log-log"),
10 | quantiles = c(0.25, 0.75)
11 | )
12 | }
13 | \arguments{
14 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
15 |
16 | \item{conf_type}{(\code{string})\cr confidence interval type. Options are "plain" (default), "log", "log-log",
17 | see more in \code{\link[survival:survfit]{survival::survfit()}}. Note option "none" is no longer supported.}
18 |
19 | \item{quantiles}{(\code{numeric(2)})\cr vector of length two specifying the quantiles of survival time.}
20 | }
21 | \value{
22 | A list of components with the same names as the arguments.
23 | }
24 | \description{
25 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
26 |
27 | This is an auxiliary function for controlling arguments for \code{survfit} model, typically used internally to specify
28 | details of \code{survfit} model for \code{\link[=s_surv_time]{s_surv_time()}}. \code{conf_level} refers to survival time estimation.
29 | }
30 |
--------------------------------------------------------------------------------
/man/control_surv_timepoint.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/control_survival.R
3 | \name{control_surv_timepoint}
4 | \alias{control_surv_timepoint}
5 | \title{Control function for \code{survfit} models for patients' survival rate at time points}
6 | \usage{
7 | control_surv_timepoint(
8 | conf_level = 0.95,
9 | conf_type = c("plain", "log", "log-log")
10 | )
11 | }
12 | \arguments{
13 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
14 |
15 | \item{conf_type}{(\code{string})\cr confidence interval type. Options are "plain" (default), "log", "log-log",
16 | see more in \code{\link[survival:survfit]{survival::survfit()}}. Note option "none" is no longer supported.}
17 | }
18 | \value{
19 | A list of components with the same names as the arguments.
20 | }
21 | \description{
22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
23 |
24 | This is an auxiliary function for controlling arguments for \code{survfit} model, typically used internally to specify
25 | details of \code{survfit} model for \code{\link[=s_surv_timepoint]{s_surv_timepoint()}}. \code{conf_level} refers to patient risk estimation at a time point.
26 | }
27 |
--------------------------------------------------------------------------------
/man/d_count_abnormal_by_baseline.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/abnormal_by_baseline.R
3 | \name{d_count_abnormal_by_baseline}
4 | \alias{d_count_abnormal_by_baseline}
5 | \title{Description function for \code{s_count_abnormal_by_baseline()}}
6 | \usage{
7 | d_count_abnormal_by_baseline(abnormal)
8 | }
9 | \arguments{
10 | \item{abnormal}{(\code{character})\cr values identifying the abnormal range level(s) in \code{.var}.}
11 | }
12 | \value{
13 | Abnormal category labels for \code{\link[=s_count_abnormal_by_baseline]{s_count_abnormal_by_baseline()}}.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 |
18 | Description function that produces the labels for \code{\link[=s_count_abnormal_by_baseline]{s_count_abnormal_by_baseline()}}.
19 | }
20 | \examples{
21 | d_count_abnormal_by_baseline("LOW")
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/man/d_count_cumulative.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/count_cumulative.R
3 | \name{d_count_cumulative}
4 | \alias{d_count_cumulative}
5 | \title{Description of cumulative count}
6 | \usage{
7 | d_count_cumulative(threshold, lower_tail = TRUE, include_eq = TRUE)
8 | }
9 | \arguments{
10 | \item{threshold}{(\code{numeric(1)})\cr a cutoff value as threshold to count values of \code{x}.}
11 |
12 | \item{lower_tail}{(\code{flag})\cr whether to count lower tail, default is \code{TRUE}.}
13 |
14 | \item{include_eq}{(\code{flag})\cr whether to include value equal to the \code{threshold} in
15 | count, default is \code{TRUE}.}
16 | }
17 | \value{
18 | Labels for \code{\link[=s_count_cumulative]{s_count_cumulative()}}.
19 | }
20 | \description{
21 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
22 |
23 | This is a helper function that describes the analysis in \code{\link[=s_count_cumulative]{s_count_cumulative()}}.
24 | }
25 |
--------------------------------------------------------------------------------
/man/d_count_missed_doses.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/count_missed_doses.R
3 | \name{d_count_missed_doses}
4 | \alias{d_count_missed_doses}
5 | \title{Description function that calculates labels for \code{s_count_missed_doses()}}
6 | \usage{
7 | d_count_missed_doses(thresholds)
8 | }
9 | \arguments{
10 | \item{thresholds}{(\code{numeric})\cr minimum number of missed doses the patients had.}
11 | }
12 | \value{
13 | \code{\link[=d_count_missed_doses]{d_count_missed_doses()}} returns a named \code{character} vector with the labels.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 | }
18 | \seealso{
19 | \code{\link[=s_count_missed_doses]{s_count_missed_doses()}}
20 | }
21 |
--------------------------------------------------------------------------------
/man/d_onco_rsp_label.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/estimate_multinomial_rsp.R
3 | \name{d_onco_rsp_label}
4 | \alias{d_onco_rsp_label}
5 | \title{Description of standard oncology response}
6 | \usage{
7 | d_onco_rsp_label(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{character})\cr the standard oncology codes to be described.}
11 | }
12 | \value{
13 | Response labels.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 |
18 | Describe the oncology response in a standard way.
19 | }
20 | \examples{
21 | d_onco_rsp_label(
22 | c("CR", "PR", "SD", "NON CR/PD", "PD", "NE", "Missing", "", "NE/Missing")
23 | )
24 |
25 | # Adding some values not considered in d_onco_rsp_label
26 |
27 | d_onco_rsp_label(
28 | c("CR", "PR", "hello", "hi")
29 | )
30 |
31 | }
32 | \seealso{
33 | \code{\link[=estimate_multinomial_rsp]{estimate_multinomial_rsp()}}
34 | }
35 |
--------------------------------------------------------------------------------
/man/d_pkparam.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/d_pkparam.R
3 | \name{d_pkparam}
4 | \alias{d_pkparam}
5 | \title{Generate PK reference dataset}
6 | \usage{
7 | d_pkparam()
8 | }
9 | \value{
10 | A \code{data.frame} of PK parameters.
11 | }
12 | \description{
13 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
14 | }
15 | \examples{
16 | pk_reference_dataset <- d_pkparam()
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/man/d_proportion.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/estimate_proportion.R
3 | \name{d_proportion}
4 | \alias{d_proportion}
5 | \title{Description of the proportion summary}
6 | \usage{
7 | d_proportion(conf_level, method, long = FALSE)
8 | }
9 | \arguments{
10 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
11 |
12 | \item{method}{(\code{string})\cr the method used to construct the confidence interval
13 | for proportion of successful outcomes; one of \code{waldcc}, \code{wald}, \code{clopper-pearson},
14 | \code{wilson}, \code{wilsonc}, \code{strat_wilson}, \code{strat_wilsonc}, \code{agresti-coull} or \code{jeffreys}.}
15 |
16 | \item{long}{(\code{flag})\cr whether a long or a short (default) description is required.}
17 | }
18 | \value{
19 | String describing the analysis.
20 | }
21 | \description{
22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
23 |
24 | This is a helper function that describes the analysis in \code{\link[=s_proportion]{s_proportion()}}.
25 | }
26 |
--------------------------------------------------------------------------------
/man/d_proportion_diff.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prop_diff.R
3 | \name{d_proportion_diff}
4 | \alias{d_proportion_diff}
5 | \title{Description of method used for proportion comparison}
6 | \usage{
7 | d_proportion_diff(conf_level, method, long = FALSE)
8 | }
9 | \arguments{
10 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
11 |
12 | \item{method}{(\code{string})\cr the method used for the confidence interval estimation.}
13 |
14 | \item{long}{(\code{flag})\cr whether a long (\code{TRUE}) or a short (\code{FALSE}, default) description is required.}
15 | }
16 | \value{
17 | A \code{string} describing the analysis.
18 | }
19 | \description{
20 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
21 |
22 | This is an auxiliary function that describes the analysis in
23 | \code{\link[=s_proportion_diff]{s_proportion_diff()}}.
24 | }
25 | \seealso{
26 | \link{prop_diff}
27 | }
28 |
--------------------------------------------------------------------------------
/man/d_rsp_subgroups_colvars.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/response_subgroups.R
3 | \name{d_rsp_subgroups_colvars}
4 | \alias{d_rsp_subgroups_colvars}
5 | \title{Labels for column variables in binary response by subgroup table}
6 | \usage{
7 | d_rsp_subgroups_colvars(vars, conf_level = NULL, method = NULL)
8 | }
9 | \arguments{
10 | \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.}
11 |
12 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
13 |
14 | \item{method}{(\code{string} or \code{NULL})\cr specifies the test used to calculate the p-value for the difference between
15 | two proportions. For options, see \code{\link[=test_proportion_diff]{test_proportion_diff()}}. Default is \code{NULL} so no test is performed.}
16 | }
17 | \value{
18 | A \code{list} of variables to tabulate and their labels.
19 | }
20 | \description{
21 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
22 |
23 | Internal function to check variables included in \code{\link[=tabulate_rsp_subgroups]{tabulate_rsp_subgroups()}} and create column labels.
24 | }
25 |
--------------------------------------------------------------------------------
/man/d_survival_subgroups_colvars.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/survival_duration_subgroups.R
3 | \name{d_survival_subgroups_colvars}
4 | \alias{d_survival_subgroups_colvars}
5 | \title{Labels for column variables in survival duration by subgroup table}
6 | \usage{
7 | d_survival_subgroups_colvars(vars, conf_level, method, time_unit = NULL)
8 | }
9 | \arguments{
10 | \item{vars}{(\code{character})\cr the names of statistics to be reported among:
11 | \itemize{
12 | \item \code{n_tot_events}: Total number of events per group.
13 | \item \code{n_events}: Number of events per group.
14 | \item \code{n_tot}: Total number of observations per group.
15 | \item \code{n}: Number of observations per group.
16 | \item \code{median}: Median survival time.
17 | \item \code{hr}: Hazard ratio.
18 | \item \code{ci}: Confidence interval of hazard ratio.
19 | \item \code{pval}: p-value of the effect.
20 | Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as both \code{hr} and \code{ci}
21 | are required.
22 | }}
23 |
24 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
25 |
26 | \item{method}{(\code{string})\cr p-value method for testing hazard ratio = 1.}
27 |
28 | \item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.}
29 | }
30 | \value{
31 | A \code{list} of variables and their labels to tabulate.
32 | }
33 | \description{
34 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
35 |
36 | Internal function to check variables included in \code{\link[=tabulate_survival_subgroups]{tabulate_survival_subgroups()}} and create column labels.
37 | }
38 | \note{
39 | At least one of \code{n_tot} and \code{n_tot_events} must be provided in \code{vars}.
40 | }
41 |
--------------------------------------------------------------------------------
/man/d_test_proportion_diff.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prop_diff_test.R
3 | \name{d_test_proportion_diff}
4 | \alias{d_test_proportion_diff}
5 | \title{Description of the difference test between two proportions}
6 | \usage{
7 | d_test_proportion_diff(method)
8 | }
9 | \arguments{
10 | \item{method}{(\code{string})\cr one of \code{chisq}, \code{cmh}, \code{fisher}, or \code{schouten}; specifies the test used
11 | to calculate the p-value.}
12 | }
13 | \value{
14 | A \code{string} describing the test from which the p-value is derived.
15 | }
16 | \description{
17 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
18 |
19 | This is an auxiliary function that describes the analysis in \code{s_test_proportion_diff}.
20 | }
21 |
--------------------------------------------------------------------------------
/man/day2month.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{day2month}
4 | \alias{day2month}
5 | \title{Conversion of days to months}
6 | \usage{
7 | day2month(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric(1)})\cr time in days.}
11 | }
12 | \value{
13 | A \code{numeric} vector with the time in months.
14 | }
15 | \description{
16 | Conversion of days to months
17 | }
18 | \examples{
19 | x <- c(403, 248, 30, 86)
20 | day2month(x)
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/man/decorate_grob_factory.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/decorate_grob.R
3 | \name{decorate_grob_factory}
4 | \alias{decorate_grob_factory}
5 | \title{Update page number}
6 | \usage{
7 | decorate_grob_factory(npages, ...)
8 | }
9 | \arguments{
10 | \item{npages}{(\code{numeric(1)})\cr total number of pages.}
11 |
12 | \item{...}{arguments passed on to \code{\link[=decorate_grob]{decorate_grob()}}.}
13 | }
14 | \value{
15 | Closure that increments the page number.
16 | }
17 | \description{
18 | Automatically updates page number.
19 | }
20 | \keyword{internal}
21 |
--------------------------------------------------------------------------------
/man/decorate_grob_set.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/decorate_grob.R
3 | \name{decorate_grob_set}
4 | \alias{decorate_grob_set}
5 | \title{Decorate set of \code{grob}s and add page numbering}
6 | \usage{
7 | decorate_grob_set(grobs, ...)
8 | }
9 | \arguments{
10 | \item{grobs}{(\code{list} of \code{grob})\cr a list of grid grobs.}
11 |
12 | \item{...}{arguments passed on to \code{\link[=decorate_grob]{decorate_grob()}}.}
13 | }
14 | \value{
15 | A decorated grob.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Note that this uses the \code{\link[=decorate_grob_factory]{decorate_grob_factory()}} function.
21 | }
22 | \examples{
23 | library(ggplot2)
24 | library(grid)
25 | g <- with(data = iris, {
26 | list(
27 | ggplot2::ggplotGrob(
28 | ggplot2::ggplot(mapping = aes(Sepal.Length, Sepal.Width, col = Species)) +
29 | ggplot2::geom_point()
30 | ),
31 | ggplot2::ggplotGrob(
32 | ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Length, col = Species)) +
33 | ggplot2::geom_point()
34 | ),
35 | ggplot2::ggplotGrob(
36 | ggplot2::ggplot(mapping = aes(Sepal.Length, Petal.Width, col = Species)) +
37 | ggplot2::geom_point()
38 | ),
39 | ggplot2::ggplotGrob(
40 | ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Length, col = Species)) +
41 | ggplot2::geom_point()
42 | ),
43 | ggplot2::ggplotGrob(
44 | ggplot2::ggplot(mapping = aes(Sepal.Width, Petal.Width, col = Species)) +
45 | ggplot2::geom_point()
46 | ),
47 | ggplot2::ggplotGrob(
48 | ggplot2::ggplot(mapping = aes(Petal.Length, Petal.Width, col = Species)) +
49 | ggplot2::geom_point()
50 | )
51 | )
52 | })
53 | lg <- decorate_grob_set(grobs = g, titles = "Hello\nOne\nTwo\nThree", footnotes = "")
54 |
55 | draw_grob(lg[[1]])
56 | draw_grob(lg[[2]])
57 | draw_grob(lg[[6]])
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/man/df2gg.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_ggplot.R
3 | \name{df2gg}
4 | \alias{df2gg}
5 | \title{Convert \code{data.frame} object to \code{ggplot} object}
6 | \usage{
7 | df2gg(
8 | df,
9 | colwidths = NULL,
10 | font_size = 10,
11 | col_labels = TRUE,
12 | col_lab_fontface = "bold",
13 | hline = TRUE,
14 | bg_fill = NULL
15 | )
16 | }
17 | \arguments{
18 | \item{df}{(\code{data.frame})\cr a data frame.}
19 |
20 | \item{colwidths}{(\code{numeric} or \code{NULL})\cr a vector of column widths. Each element's position in
21 | \code{colwidths} corresponds to the column of \code{df} in the same position. If \code{NULL}, column widths
22 | are calculated according to maximum number of characters per column.}
23 |
24 | \item{font_size}{(\code{numeric(1)})\cr font size.}
25 |
26 | \item{col_labels}{(\code{flag})\cr whether the column names (labels) of \code{df} should be used as the first row
27 | of the output table.}
28 |
29 | \item{col_lab_fontface}{(\code{string})\cr font face to apply to the first row (of column labels
30 | if \code{col_labels = TRUE}). Defaults to \code{"bold"}.}
31 |
32 | \item{hline}{(\code{flag})\cr whether a horizontal line should be printed below the first row of the table.}
33 |
34 | \item{bg_fill}{(\code{string})\cr table background fill color.}
35 | }
36 | \value{
37 | A \code{ggplot} object.
38 | }
39 | \description{
40 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
41 |
42 | Given a \code{data.frame} object, performs basic conversion to a \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} object built using
43 | functions from the \code{ggplot2} package.
44 | }
45 | \examples{
46 | \dontrun{
47 | df2gg(head(iris, 5))
48 |
49 | df2gg(head(iris, 5), font_size = 15, colwidths = c(1, 1, 1, 1, 1))
50 | }
51 | }
52 | \keyword{internal}
53 |
--------------------------------------------------------------------------------
/man/dot-is_equal_float.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{.is_equal_float}
4 | \alias{.is_equal_float}
5 | \title{Utility function to check if a float value is equal to another float value}
6 | \usage{
7 | .is_equal_float(x, y)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric(1)})\cr a float number.}
11 |
12 | \item{y}{(\code{numeric(1)})\cr a float number.}
13 | }
14 | \value{
15 | \code{TRUE} if identical, otherwise \code{FALSE}.
16 | }
17 | \description{
18 | Uses \code{.Machine$double.eps} as the tolerance for the comparison.
19 | }
20 | \keyword{internal}
21 |
--------------------------------------------------------------------------------
/man/draw_grob.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_grid.R
3 | \name{draw_grob}
4 | \alias{draw_grob}
5 | \title{Draw \code{grob}}
6 | \usage{
7 | draw_grob(grob, newpage = TRUE, vp = NULL)
8 | }
9 | \arguments{
10 | \item{grob}{(\code{grob})\cr grid object.}
11 |
12 | \item{newpage}{(\code{flag})\cr draw on a new page.}
13 |
14 | \item{vp}{(\code{viewport} or \code{NULL})\cr a \code{\link[=viewport]{viewport()}} object (or \code{NULL}).}
15 | }
16 | \value{
17 | A \code{grob}.
18 | }
19 | \description{
20 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
21 |
22 | Draw grob on device page.
23 | }
24 | \examples{
25 | library(dplyr)
26 | library(grid)
27 |
28 | \donttest{
29 | rect <- rectGrob(width = grid::unit(0.5, "npc"), height = grid::unit(0.5, "npc"))
30 | rect \%>\% draw_grob(vp = grid::viewport(angle = 45))
31 |
32 | num <- lapply(1:10, textGrob)
33 | num \%>\%
34 | arrange_grobs(grobs = .) \%>\%
35 | draw_grob()
36 | showViewport()
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/man/empty_vector_if_na.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{empty_vector_if_na}
4 | \alias{empty_vector_if_na}
5 | \title{Return an empty numeric if all elements are \code{NA}.}
6 | \usage{
7 | empty_vector_if_na(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric})\cr vector.}
11 | }
12 | \value{
13 | An empty \code{numeric} if all elements of \code{x} are \code{NA}, otherwise \code{x}.
14 | }
15 | \description{
16 | Return an empty numeric if all elements are \code{NA}.
17 | }
18 | \examples{
19 | x <- c(NA, NA, NA)
20 | # Internal function - empty_vector_if_na
21 | }
22 | \keyword{internal}
23 |
--------------------------------------------------------------------------------
/man/ex_data.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data.R
3 | \docType{data}
4 | \name{ex_data}
5 | \alias{ex_data}
6 | \alias{tern_ex_adsl}
7 | \alias{tern_ex_adae}
8 | \alias{tern_ex_adlb}
9 | \alias{tern_ex_adpp}
10 | \alias{tern_ex_adrs}
11 | \alias{tern_ex_adtte}
12 | \title{Simulated CDISC data for examples}
13 | \format{
14 | \code{rds} (\code{data.frame})
15 |
16 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 200 rows and 21 columns.
17 |
18 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 541 rows and 42 columns.
19 |
20 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 4200 rows and 50 columns.
21 |
22 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 522 rows and 25 columns.
23 |
24 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1600 rows and 29 columns.
25 |
26 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1000 rows and 28 columns.
27 | }
28 | \usage{
29 | tern_ex_adsl
30 |
31 | tern_ex_adae
32 |
33 | tern_ex_adlb
34 |
35 | tern_ex_adpp
36 |
37 | tern_ex_adrs
38 |
39 | tern_ex_adtte
40 | }
41 | \description{
42 | Simulated CDISC data for examples
43 | }
44 | \section{Functions}{
45 | \itemize{
46 | \item \code{tern_ex_adsl}: ADSL data
47 |
48 | \item \code{tern_ex_adae}: ADAE data
49 |
50 | \item \code{tern_ex_adlb}: ADLB data
51 |
52 | \item \code{tern_ex_adpp}: ADPP data
53 |
54 | \item \code{tern_ex_adrs}: ADRS data
55 |
56 | \item \code{tern_ex_adtte}: ADTTE data
57 |
58 | }}
59 | \keyword{datasets}
60 |
--------------------------------------------------------------------------------
/man/explicit_na.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/missing_data.R
3 | \name{explicit_na}
4 | \alias{explicit_na}
5 | \title{Missing data}
6 | \usage{
7 | explicit_na(x, label = "")
8 | }
9 | \arguments{
10 | \item{x}{(\code{factor} or \code{character})\cr values for which any missing values should be substituted.}
11 |
12 | \item{label}{(\code{string})\cr string that missing data should be replaced with.}
13 | }
14 | \value{
15 | \code{x} with any \code{NA} values substituted by \code{label}.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Substitute missing data with a string or factor level.
21 | }
22 | \examples{
23 | explicit_na(c(NA, "a", "b"))
24 | is.na(explicit_na(c(NA, "a", "b")))
25 |
26 | explicit_na(factor(c(NA, "a", "b")))
27 | is.na(explicit_na(factor(c(NA, "a", "b"))))
28 |
29 | explicit_na(sas_na(c("a", "")))
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/man/extract_by_name.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{extract_by_name}
4 | \alias{extract_by_name}
5 | \title{Extract elements by name}
6 | \usage{
7 | extract_by_name(x, names)
8 | }
9 | \arguments{
10 | \item{x}{(named \code{vector})\cr where to extract named elements from.}
11 |
12 | \item{names}{(\code{character})\cr vector of names to extract.}
13 | }
14 | \value{
15 | \code{NULL} if \code{x} is \code{NULL}, otherwise the extracted elements from \code{x}.
16 | }
17 | \description{
18 | This utility function extracts elements from a vector \code{x} by \code{names}.
19 | Differences to the standard \code{[} function are:
20 | }
21 | \details{
22 | \itemize{
23 | \item If \code{x} is \code{NULL}, then still always \code{NULL} is returned (same as in base function).
24 | \item If \code{x} is not \code{NULL}, then the intersection of its names is made with \code{names} and those
25 | elements are returned. That is, \code{names} which don't appear in \code{x} are not returned as \code{NA}s.
26 | }
27 | }
28 | \keyword{internal}
29 |
--------------------------------------------------------------------------------
/man/f_conf_level.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{f_conf_level}
4 | \alias{f_conf_level}
5 | \title{Utility function to create label for confidence interval}
6 | \usage{
7 | f_conf_level(conf_level)
8 | }
9 | \arguments{
10 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
11 | }
12 | \value{
13 | A \code{string}.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 | }
18 |
--------------------------------------------------------------------------------
/man/f_pval.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{f_pval}
4 | \alias{f_pval}
5 | \title{Utility function to create label for p-value}
6 | \usage{
7 | f_pval(test_mean)
8 | }
9 | \arguments{
10 | \item{test_mean}{(\code{numeric(1)})\cr mean value to test under the null hypothesis.}
11 | }
12 | \value{
13 | A \code{string}.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 | }
18 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-archived.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-defunct.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-deprecated.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-experimental.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-maturing.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-questioning.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-soft-deprecated.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-stable.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/lifecycle-superseded.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/figures/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/man/figures/logo.png
--------------------------------------------------------------------------------
/man/forest_viewport.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/g_forest.R
3 | \name{forest_viewport}
4 | \alias{forest_viewport}
5 | \title{Create a viewport tree for the forest plot}
6 | \usage{
7 | forest_viewport(
8 | tbl,
9 | width_row_names = NULL,
10 | width_columns = NULL,
11 | width_forest = grid::unit(1, "null"),
12 | gap_column = grid::unit(1, "lines"),
13 | gap_header = grid::unit(1, "lines"),
14 | mat_form = NULL
15 | )
16 | }
17 | \arguments{
18 | \item{tbl}{(\code{VTableTree})\cr \code{rtables} table object.}
19 |
20 | \item{width_row_names}{(\code{grid::unit})\cr width of row names.}
21 |
22 | \item{width_columns}{(\code{grid::unit})\cr width of column spans.}
23 |
24 | \item{width_forest}{(\code{grid::unit})\cr width of the forest plot.}
25 |
26 | \item{gap_column}{(\code{grid::unit})\cr gap width between the columns.}
27 |
28 | \item{gap_header}{(\code{grid::unit})\cr gap width between the header.}
29 |
30 | \item{mat_form}{(\code{MatrixPrintForm})\cr matrix print form of the table.}
31 | }
32 | \value{
33 | A viewport tree.
34 | }
35 | \description{
36 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
37 | }
38 | \examples{
39 | library(grid)
40 |
41 | tbl <- rtable(
42 | header = rheader(
43 | rrow("", "E", rcell("CI", colspan = 2)),
44 | rrow("", "A", "B", "C")
45 | ),
46 | rrow("row 1", 1, 0.8, 1.1),
47 | rrow("row 2", 1.4, 0.8, 1.6),
48 | rrow("row 3", 1.2, 0.8, 1.2)
49 | )
50 |
51 | \donttest{
52 | v <- forest_viewport(tbl)
53 |
54 | grid::grid.newpage()
55 | showViewport(v)
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/man/format_count_fraction.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_count_fraction}
4 | \alias{format_count_fraction}
5 | \title{Format count and fraction}
6 | \usage{
7 | format_count_fraction(x, ...)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric(2)})\cr vector of length 2 with count and fraction, respectively.}
11 |
12 | \item{...}{not used. Required for \code{rtables} interface.}
13 | }
14 | \value{
15 | A string in the format \verb{count (fraction \%)}. If \code{count} is 0, the format is \code{0}.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Formats a count together with fraction with special consideration when count is \code{0}.
21 | }
22 | \examples{
23 | format_count_fraction(x = c(2, 0.6667))
24 | format_count_fraction(x = c(0, 0))
25 |
26 | }
27 | \seealso{
28 | Other formatting functions:
29 | \code{\link{extreme_format}},
30 | \code{\link{format_auto}()},
31 | \code{\link{format_count_fraction_fixed_dp}()},
32 | \code{\link{format_count_fraction_lt10}()},
33 | \code{\link{format_extreme_values}()},
34 | \code{\link{format_extreme_values_ci}()},
35 | \code{\link{format_fraction}()},
36 | \code{\link{format_fraction_fixed_dp}()},
37 | \code{\link{format_fraction_threshold}()},
38 | \code{\link{format_sigfig}()},
39 | \code{\link{format_xx}()},
40 | \code{\link{formatting_functions}}
41 | }
42 | \concept{formatting functions}
43 |
--------------------------------------------------------------------------------
/man/format_count_fraction_fixed_dp.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_count_fraction_fixed_dp}
4 | \alias{format_count_fraction_fixed_dp}
5 | \title{Format count and percentage with fixed single decimal place}
6 | \usage{
7 | format_count_fraction_fixed_dp(x, ...)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric(2)})\cr vector of length 2 with count and fraction, respectively.}
11 |
12 | \item{...}{not used. Required for \code{rtables} interface.}
13 | }
14 | \value{
15 | A string in the format \verb{count (fraction \%)}. If \code{count} is 0, the format is \code{0}.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
19 |
20 | Formats a count together with fraction with special consideration when count is \code{0}.
21 | }
22 | \examples{
23 | format_count_fraction_fixed_dp(x = c(2, 0.6667))
24 | format_count_fraction_fixed_dp(x = c(2, 0.5))
25 | format_count_fraction_fixed_dp(x = c(0, 0))
26 |
27 | }
28 | \seealso{
29 | Other formatting functions:
30 | \code{\link{extreme_format}},
31 | \code{\link{format_auto}()},
32 | \code{\link{format_count_fraction}()},
33 | \code{\link{format_count_fraction_lt10}()},
34 | \code{\link{format_extreme_values}()},
35 | \code{\link{format_extreme_values_ci}()},
36 | \code{\link{format_fraction}()},
37 | \code{\link{format_fraction_fixed_dp}()},
38 | \code{\link{format_fraction_threshold}()},
39 | \code{\link{format_sigfig}()},
40 | \code{\link{format_xx}()},
41 | \code{\link{formatting_functions}}
42 | }
43 | \concept{formatting functions}
44 |
--------------------------------------------------------------------------------
/man/format_count_fraction_lt10.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_count_fraction_lt10}
4 | \alias{format_count_fraction_lt10}
5 | \title{Format count and fraction with special case for count < 10}
6 | \usage{
7 | format_count_fraction_lt10(x, ...)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric(2)})\cr vector of length 2 with count and fraction, respectively.}
11 |
12 | \item{...}{not used. Required for \code{rtables} interface.}
13 | }
14 | \value{
15 | A string in the format \verb{count (fraction \%)}. If \code{count} is less than 10, only \code{count} is printed.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Formats a count together with fraction with special consideration when count is less than 10.
21 | }
22 | \examples{
23 | format_count_fraction_lt10(x = c(275, 0.9673))
24 | format_count_fraction_lt10(x = c(2, 0.6667))
25 | format_count_fraction_lt10(x = c(9, 1))
26 |
27 | }
28 | \seealso{
29 | Other formatting functions:
30 | \code{\link{extreme_format}},
31 | \code{\link{format_auto}()},
32 | \code{\link{format_count_fraction}()},
33 | \code{\link{format_count_fraction_fixed_dp}()},
34 | \code{\link{format_extreme_values}()},
35 | \code{\link{format_extreme_values_ci}()},
36 | \code{\link{format_fraction}()},
37 | \code{\link{format_fraction_fixed_dp}()},
38 | \code{\link{format_fraction_threshold}()},
39 | \code{\link{format_sigfig}()},
40 | \code{\link{format_xx}()},
41 | \code{\link{formatting_functions}}
42 | }
43 | \concept{formatting functions}
44 |
--------------------------------------------------------------------------------
/man/format_extreme_values.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_extreme_values}
4 | \alias{format_extreme_values}
5 | \title{Format a single extreme value}
6 | \usage{
7 | format_extreme_values(digits = 2L)
8 | }
9 | \arguments{
10 | \item{digits}{(\code{integer(1)})\cr number of decimal places to display.}
11 | }
12 | \value{
13 | An \code{rtables} formatting function that uses threshold \code{digits} to return a formatted extreme value.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 |
18 | Create a formatting function for a single extreme value.
19 | }
20 | \examples{
21 | format_fun <- format_extreme_values(2L)
22 | format_fun(x = 0.127)
23 | format_fun(x = Inf)
24 | format_fun(x = 0)
25 | format_fun(x = 0.009)
26 |
27 | }
28 | \seealso{
29 | Other formatting functions:
30 | \code{\link{extreme_format}},
31 | \code{\link{format_auto}()},
32 | \code{\link{format_count_fraction}()},
33 | \code{\link{format_count_fraction_fixed_dp}()},
34 | \code{\link{format_count_fraction_lt10}()},
35 | \code{\link{format_extreme_values_ci}()},
36 | \code{\link{format_fraction}()},
37 | \code{\link{format_fraction_fixed_dp}()},
38 | \code{\link{format_fraction_threshold}()},
39 | \code{\link{format_sigfig}()},
40 | \code{\link{format_xx}()},
41 | \code{\link{formatting_functions}}
42 | }
43 | \concept{formatting functions}
44 |
--------------------------------------------------------------------------------
/man/format_extreme_values_ci.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_extreme_values_ci}
4 | \alias{format_extreme_values_ci}
5 | \title{Format extreme values part of a confidence interval}
6 | \usage{
7 | format_extreme_values_ci(digits = 2L)
8 | }
9 | \arguments{
10 | \item{digits}{(\code{integer(1)})\cr number of decimal places to display.}
11 | }
12 | \value{
13 | An \code{rtables} formatting function that uses threshold \code{digits} to return a formatted extreme
14 | values confidence interval.
15 | }
16 | \description{
17 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
18 |
19 | Formatting Function for extreme values part of a confidence interval. Values
20 | are formatted as e.g. "(xx.xx, xx.xx)" if the number of \code{digits} is 2.
21 | }
22 | \examples{
23 | format_fun <- format_extreme_values_ci(2L)
24 | format_fun(x = c(0.127, Inf))
25 | format_fun(x = c(0, 0.009))
26 |
27 | }
28 | \seealso{
29 | Other formatting functions:
30 | \code{\link{extreme_format}},
31 | \code{\link{format_auto}()},
32 | \code{\link{format_count_fraction}()},
33 | \code{\link{format_count_fraction_fixed_dp}()},
34 | \code{\link{format_count_fraction_lt10}()},
35 | \code{\link{format_extreme_values}()},
36 | \code{\link{format_fraction}()},
37 | \code{\link{format_fraction_fixed_dp}()},
38 | \code{\link{format_fraction_threshold}()},
39 | \code{\link{format_sigfig}()},
40 | \code{\link{format_xx}()},
41 | \code{\link{formatting_functions}}
42 | }
43 | \concept{formatting functions}
44 |
--------------------------------------------------------------------------------
/man/format_fraction.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_fraction}
4 | \alias{format_fraction}
5 | \title{Format fraction and percentage}
6 | \usage{
7 | format_fraction(x, ...)
8 | }
9 | \arguments{
10 | \item{x}{(named \code{integer})\cr vector with elements \code{num} and \code{denom}.}
11 |
12 | \item{...}{not used. Required for \code{rtables} interface.}
13 | }
14 | \value{
15 | A string in the format \verb{num / denom (ratio \%)}. If \code{num} is 0, the format is \code{num / denom}.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Formats a fraction together with ratio in percent.
21 | }
22 | \examples{
23 | format_fraction(x = c(num = 2L, denom = 3L))
24 | format_fraction(x = c(num = 0L, denom = 3L))
25 |
26 | }
27 | \seealso{
28 | Other formatting functions:
29 | \code{\link{extreme_format}},
30 | \code{\link{format_auto}()},
31 | \code{\link{format_count_fraction}()},
32 | \code{\link{format_count_fraction_fixed_dp}()},
33 | \code{\link{format_count_fraction_lt10}()},
34 | \code{\link{format_extreme_values}()},
35 | \code{\link{format_extreme_values_ci}()},
36 | \code{\link{format_fraction_fixed_dp}()},
37 | \code{\link{format_fraction_threshold}()},
38 | \code{\link{format_sigfig}()},
39 | \code{\link{format_xx}()},
40 | \code{\link{formatting_functions}}
41 | }
42 | \concept{formatting functions}
43 |
--------------------------------------------------------------------------------
/man/format_fraction_fixed_dp.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_fraction_fixed_dp}
4 | \alias{format_fraction_fixed_dp}
5 | \title{Format fraction and percentage with fixed single decimal place}
6 | \usage{
7 | format_fraction_fixed_dp(x, ...)
8 | }
9 | \arguments{
10 | \item{x}{(named \code{integer})\cr vector with elements \code{num} and \code{denom}.}
11 |
12 | \item{...}{not used. Required for \code{rtables} interface.}
13 | }
14 | \value{
15 | A string in the format \verb{num / denom (ratio \%)}. If \code{num} is 0, the format is \code{num / denom}.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Formats a fraction together with ratio in percent with fixed single decimal place.
21 | Includes trailing zero in case of whole number percentages to always keep one decimal place.
22 | }
23 | \examples{
24 | format_fraction_fixed_dp(x = c(num = 1L, denom = 2L))
25 | format_fraction_fixed_dp(x = c(num = 1L, denom = 4L))
26 | format_fraction_fixed_dp(x = c(num = 0L, denom = 3L))
27 |
28 | }
29 | \seealso{
30 | Other formatting functions:
31 | \code{\link{extreme_format}},
32 | \code{\link{format_auto}()},
33 | \code{\link{format_count_fraction}()},
34 | \code{\link{format_count_fraction_fixed_dp}()},
35 | \code{\link{format_count_fraction_lt10}()},
36 | \code{\link{format_extreme_values}()},
37 | \code{\link{format_extreme_values_ci}()},
38 | \code{\link{format_fraction}()},
39 | \code{\link{format_fraction_threshold}()},
40 | \code{\link{format_sigfig}()},
41 | \code{\link{format_xx}()},
42 | \code{\link{formatting_functions}}
43 | }
44 | \concept{formatting functions}
45 |
--------------------------------------------------------------------------------
/man/format_fraction_threshold.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_fraction_threshold}
4 | \alias{format_fraction_threshold}
5 | \title{Format fraction with lower threshold}
6 | \usage{
7 | format_fraction_threshold(threshold)
8 | }
9 | \arguments{
10 | \item{threshold}{(\code{proportion})\cr lower threshold.}
11 | }
12 | \value{
13 | An \code{rtables} formatting function that takes numeric input \code{x} where the second
14 | element is the fraction that is formatted. If the fraction is above or equal to the threshold,
15 | then it is displayed in percentage. If it is positive but below the threshold, it returns,
16 | e.g. "<1" if the threshold is \code{0.01}. If it is zero, then just "0" is returned.
17 | }
18 | \description{
19 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
20 |
21 | Formats a fraction when the second element of the input \code{x} is the fraction. It applies
22 | a lower threshold, below which it is just stated that the fraction is smaller than that.
23 | }
24 | \examples{
25 | format_fun <- format_fraction_threshold(0.05)
26 | format_fun(x = c(20, 0.1))
27 | format_fun(x = c(2, 0.01))
28 | format_fun(x = c(0, 0))
29 |
30 | }
31 | \seealso{
32 | Other formatting functions:
33 | \code{\link{extreme_format}},
34 | \code{\link{format_auto}()},
35 | \code{\link{format_count_fraction}()},
36 | \code{\link{format_count_fraction_fixed_dp}()},
37 | \code{\link{format_count_fraction_lt10}()},
38 | \code{\link{format_extreme_values}()},
39 | \code{\link{format_extreme_values_ci}()},
40 | \code{\link{format_fraction}()},
41 | \code{\link{format_fraction_fixed_dp}()},
42 | \code{\link{format_sigfig}()},
43 | \code{\link{format_xx}()},
44 | \code{\link{formatting_functions}}
45 | }
46 | \concept{formatting functions}
47 |
--------------------------------------------------------------------------------
/man/format_sigfig.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_sigfig}
4 | \alias{format_sigfig}
5 | \title{Format numeric values by significant figures}
6 | \usage{
7 | format_sigfig(sigfig, format = "xx", num_fmt = "fg")
8 | }
9 | \arguments{
10 | \item{sigfig}{(\code{integer(1)})\cr number of significant figures to display.}
11 |
12 | \item{format}{(\code{string})\cr the format label (string) to apply when printing the value. Decimal
13 | places in string are ignored in favor of formatting by significant figures. Formats options are:
14 | \code{"xx"}, \code{"xx / xx"}, \code{"(xx, xx)"}, \code{"xx - xx"}, and \code{"xx (xx)"}.}
15 |
16 | \item{num_fmt}{(\code{string})\cr numeric format modifiers to apply to the value. Defaults to \code{"fg"} for
17 | standard significant figures formatting - fixed (non-scientific notation) format (\code{"f"})
18 | and \code{sigfig} equal to number of significant figures instead of decimal places (\code{"g"}). See the
19 | \code{\link[=formatC]{formatC()}} \code{format} argument for more options.}
20 | }
21 | \value{
22 | An \code{rtables} formatting function.
23 | }
24 | \description{
25 | Format numeric values to print with a specified number of significant figures.
26 | }
27 | \examples{
28 | fmt_3sf <- format_sigfig(3)
29 | fmt_3sf(1.658)
30 | fmt_3sf(1e1)
31 |
32 | fmt_5sf <- format_sigfig(5)
33 | fmt_5sf(0.57)
34 | fmt_5sf(0.000025645)
35 |
36 | }
37 | \seealso{
38 | Other formatting functions:
39 | \code{\link{extreme_format}},
40 | \code{\link{format_auto}()},
41 | \code{\link{format_count_fraction}()},
42 | \code{\link{format_count_fraction_fixed_dp}()},
43 | \code{\link{format_count_fraction_lt10}()},
44 | \code{\link{format_extreme_values}()},
45 | \code{\link{format_extreme_values_ci}()},
46 | \code{\link{format_fraction}()},
47 | \code{\link{format_fraction_fixed_dp}()},
48 | \code{\link{format_fraction_threshold}()},
49 | \code{\link{format_xx}()},
50 | \code{\link{formatting_functions}}
51 | }
52 | \concept{formatting functions}
53 |
--------------------------------------------------------------------------------
/man/format_xx.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{format_xx}
4 | \alias{format_xx}
5 | \title{Format XX as a formatting function}
6 | \usage{
7 | format_xx(str)
8 | }
9 | \arguments{
10 | \item{str}{(\code{string})\cr template.}
11 | }
12 | \value{
13 | An \code{rtables} formatting function.
14 | }
15 | \description{
16 | Translate a string where x and dots are interpreted as number place
17 | holders, and others as formatting elements.
18 | }
19 | \examples{
20 | test <- list(c(1.658, 0.5761), c(1e1, 785.6))
21 |
22 | z <- format_xx("xx (xx.x)")
23 | sapply(test, z)
24 |
25 | z <- format_xx("xx.x - xx.x")
26 | sapply(test, z)
27 |
28 | z <- format_xx("xx.x, incl. xx.x\% NE")
29 | sapply(test, z)
30 |
31 | }
32 | \seealso{
33 | Other formatting functions:
34 | \code{\link{extreme_format}},
35 | \code{\link{format_auto}()},
36 | \code{\link{format_count_fraction}()},
37 | \code{\link{format_count_fraction_fixed_dp}()},
38 | \code{\link{format_count_fraction_lt10}()},
39 | \code{\link{format_extreme_values}()},
40 | \code{\link{format_extreme_values_ci}()},
41 | \code{\link{format_fraction}()},
42 | \code{\link{format_fraction_fixed_dp}()},
43 | \code{\link{format_fraction_threshold}()},
44 | \code{\link{format_sigfig}()},
45 | \code{\link{formatting_functions}}
46 | }
47 | \concept{formatting functions}
48 |
--------------------------------------------------------------------------------
/man/formatting_functions.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/formatting_functions.R
3 | \name{formatting_functions}
4 | \alias{formatting_functions}
5 | \title{Formatting functions}
6 | \description{
7 | See below for the list of formatting functions created in \code{tern} to work with \code{rtables}.
8 | }
9 | \details{
10 | Other available formats can be listed via \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}}. Additional
11 | custom formats can be created via the \code{\link[formatters:sprintf_format]{formatters::sprintf_format()}} function.
12 | }
13 | \seealso{
14 | Other formatting functions:
15 | \code{\link{extreme_format}},
16 | \code{\link{format_auto}()},
17 | \code{\link{format_count_fraction}()},
18 | \code{\link{format_count_fraction_fixed_dp}()},
19 | \code{\link{format_count_fraction_lt10}()},
20 | \code{\link{format_extreme_values}()},
21 | \code{\link{format_extreme_values_ci}()},
22 | \code{\link{format_fraction}()},
23 | \code{\link{format_fraction_fixed_dp}()},
24 | \code{\link{format_fraction_threshold}()},
25 | \code{\link{format_sigfig}()},
26 | \code{\link{format_xx}()}
27 | }
28 | \concept{formatting functions}
29 |
--------------------------------------------------------------------------------
/man/g_bland_altman.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/bland_altman.R
3 | \name{g_bland_altman}
4 | \alias{g_bland_altman}
5 | \alias{bland_altman}
6 | \title{Bland-Altman plot}
7 | \usage{
8 | g_bland_altman(x, y, conf_level = 0.95)
9 | }
10 | \arguments{
11 | \item{x}{(\code{numeric})\cr vector of numbers we want to analyze.}
12 |
13 | \item{y}{(\code{numeric})\cr vector of numbers we want to analyze, to be compared with \code{x}.}
14 |
15 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
16 | }
17 | \value{
18 | A \code{ggplot} Bland-Altman plot.
19 | }
20 | \description{
21 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
22 |
23 | Graphing function that produces a Bland-Altman plot.
24 | }
25 | \examples{
26 | x <- seq(1, 60, 5)
27 | y <- seq(5, 50, 4)
28 |
29 | g_bland_altman(x = x, y = y, conf_level = 0.9)
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/man/get_covariates.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{get_covariates}
4 | \alias{get_covariates}
5 | \title{Utility function to return a named list of covariate names}
6 | \usage{
7 | get_covariates(covariates)
8 | }
9 | \arguments{
10 | \item{covariates}{(\code{character})\cr a vector that can contain single variable names (such as
11 | \code{"X1"}), and/or interaction terms indicated by \code{"X1 * X2"}.}
12 | }
13 | \value{
14 | A named \code{list} of \code{character} vector.
15 | }
16 | \description{
17 | Utility function to return a named list of covariate names
18 | }
19 | \keyword{internal}
20 |
--------------------------------------------------------------------------------
/man/get_smooths.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{get_smooths}
4 | \alias{get_smooths}
5 | \title{Smooth function with optional grouping}
6 | \usage{
7 | get_smooths(df, x, y, groups = NULL, level = 0.95)
8 | }
9 | \arguments{
10 | \item{df}{(\code{data.frame})\cr data set containing all analysis variables.}
11 |
12 | \item{x}{(\code{string})\cr x column name.}
13 |
14 | \item{y}{(\code{string})\cr y column name.}
15 |
16 | \item{groups}{(\code{character} or \code{NULL})\cr vector with optional grouping variables names.}
17 |
18 | \item{level}{(\code{proportion})\cr level of confidence interval to use (0.95 by default).}
19 | }
20 | \value{
21 | A \code{data.frame} with original \code{x}, smoothed \code{y}, \code{ylow}, and \code{yhigh}, and
22 | optional \code{groups} variables formatted as \code{factor} type.
23 | }
24 | \description{
25 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
26 |
27 | This produces \code{loess} smoothed estimates of \code{y} with Student confidence intervals.
28 | }
29 |
--------------------------------------------------------------------------------
/man/groups_list_to_df.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/split_cols_by_groups.R
3 | \name{groups_list_to_df}
4 | \alias{groups_list_to_df}
5 | \title{Convert list of groups to a data frame}
6 | \usage{
7 | groups_list_to_df(groups_list)
8 | }
9 | \arguments{
10 | \item{groups_list}{(named \code{list} of \code{character})\cr specifies the new group levels via the names and the
11 | levels that belong to it in the character vectors that are elements of the list.}
12 | }
13 | \value{
14 | A \code{tibble} in the required format.
15 | }
16 | \description{
17 | This converts a list of group levels into a data frame format which is expected by \code{\link[rtables:add_overall_level]{rtables::add_combo_levels()}}.
18 | }
19 | \examples{
20 | grade_groups <- list(
21 | "Any Grade (\%)" = c("1", "2", "3", "4", "5"),
22 | "Grade 3-4 (\%)" = c("3", "4"),
23 | "Grade 5 (\%)" = "5"
24 | )
25 | groups_list_to_df(grade_groups)
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/man/h_ancova.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summarize_ancova.R
3 | \name{h_ancova}
4 | \alias{h_ancova}
5 | \title{Helper function to return results of a linear model}
6 | \usage{
7 | h_ancova(
8 | .var,
9 | .df_row,
10 | variables,
11 | interaction_item = NULL,
12 | weights_emmeans = NULL
13 | )
14 | }
15 | \arguments{
16 | \item{.var}{(\code{string})\cr single variable name that is passed by \code{rtables} when requested
17 | by a statistics function.}
18 |
19 | \item{.df_row}{(\code{data.frame})\cr data set that includes all the variables that are called in \code{.var} and \code{variables}.}
20 |
21 | \item{variables}{(named \code{list} of \code{string})\cr list of additional analysis variables, with expected elements:
22 | \itemize{
23 | \item \code{arm} (\code{string})\cr group variable, for which the covariate adjusted means of multiple groups will be
24 | summarized. Specifically, the first level of \code{arm} variable is taken as the reference group.
25 | \item \code{covariates} (\code{character})\cr a vector that can contain single variable names (such as \code{"X1"}), and/or
26 | interaction terms indicated by \code{"X1 * X2"}.
27 | }}
28 |
29 | \item{interaction_item}{(\code{string} or \code{NULL})\cr name of the variable that should have interactions
30 | with arm. if the interaction is not needed, the default option is \code{NULL}.}
31 |
32 | \item{weights_emmeans}{(\code{string} or \code{NULL})\cr argument from \code{\link[emmeans:emmeans]{emmeans::emmeans()}}}
33 | }
34 | \value{
35 | The summary of a linear model.
36 | }
37 | \description{
38 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
39 | }
40 | \examples{
41 | h_ancova(
42 | .var = "Sepal.Length",
43 | .df_row = iris,
44 | variables = list(arm = "Species", covariates = c("Petal.Length * Petal.Width", "Sepal.Width"))
45 | )
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/man/h_col_indices.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{h_col_indices}
4 | \alias{h_col_indices}
5 | \title{Obtain column indices}
6 | \usage{
7 | h_col_indices(table_tree, col_names)
8 | }
9 | \arguments{
10 | \item{table_tree}{(\code{VTableTree})\cr \code{rtables} table object to extract the indices from.}
11 |
12 | \item{col_names}{(\code{character})\cr vector of column names.}
13 | }
14 | \value{
15 | A vector of column indices.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Helper function to extract column indices from a \code{VTableTree} for a given
21 | vector of column names.
22 | }
23 |
--------------------------------------------------------------------------------
/man/h_data_plot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_km.R
3 | \name{h_data_plot}
4 | \alias{h_data_plot}
5 | \title{Helper function to tidy survival fit data}
6 | \usage{
7 | h_data_plot(fit_km, armval = "All", max_time = NULL)
8 | }
9 | \arguments{
10 | \item{fit_km}{(\code{survfit})\cr result of \code{\link[survival:survfit]{survival::survfit()}}.}
11 |
12 | \item{armval}{(\code{string})\cr used as strata name when treatment arm variable only has one level. Default is \code{"All"}.}
13 |
14 | \item{max_time}{(\code{numeric(1)})\cr maximum value to show on x-axis. Only data values less than or up to
15 | this threshold value will be plotted (defaults to \code{NULL}).}
16 | }
17 | \value{
18 | A \code{tibble} with columns \code{time}, \code{n.risk}, \code{n.event}, \code{n.censor}, \code{estimate}, \code{std.error}, \code{conf.high},
19 | \code{conf.low}, \code{strata}, and \code{censor}.
20 | }
21 | \description{
22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
23 |
24 | Convert the survival fit data into a data frame designed for plotting
25 | within \code{g_km}.
26 |
27 | This starts from the \code{\link[broom:reexports]{broom::tidy()}} result, and then:
28 | \itemize{
29 | \item Post-processes the \code{strata} column into a factor.
30 | \item Extends each stratum by an additional first row with time 0 and probability 1 so that
31 | downstream plot lines start at those coordinates.
32 | \item Adds a \code{censor} column.
33 | \item Filters the rows before \code{max_time}.
34 | }
35 | }
36 | \examples{
37 | library(dplyr)
38 | library(survival)
39 |
40 | # Test with multiple arms
41 | tern_ex_adtte \%>\%
42 | filter(PARAMCD == "OS") \%>\%
43 | survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\%
44 | h_data_plot()
45 |
46 | # Test with single arm
47 | tern_ex_adtte \%>\%
48 | filter(PARAMCD == "OS", ARMCD == "ARM B") \%>\%
49 | survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\%
50 | h_data_plot(armval = "ARM B")
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/man/h_decompose_gg.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_km.R
3 | \name{h_decompose_gg}
4 | \alias{h_decompose_gg}
5 | \title{\code{ggplot} decomposition}
6 | \usage{
7 | h_decompose_gg(gg)
8 | }
9 | \arguments{
10 | \item{gg}{(\code{ggplot})\cr a graphic to decompose.}
11 | }
12 | \value{
13 | A named \code{list} with elements:
14 | \itemize{
15 | \item \code{panel}: The panel.
16 | \item \code{yaxis}: The y-axis.
17 | \item \code{xaxis}: The x-axis.
18 | \item \code{xlab}: The x-axis label.
19 | \item \code{ylab}: The y-axis label.
20 | \item \code{guide}: The legend.
21 | }
22 | }
23 | \description{
24 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
25 |
26 | The elements composing the \code{ggplot} are extracted and organized in a \code{list}.
27 | }
28 | \examples{
29 | \donttest{
30 | library(dplyr)
31 | library(survival)
32 | library(grid)
33 |
34 | fit_km <- tern_ex_adtte \%>\%
35 | filter(PARAMCD == "OS") \%>\%
36 | survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .)
37 | data_plot <- h_data_plot(fit_km = fit_km)
38 | xticks <- h_xticks(data = data_plot)
39 | gg <- h_ggkm(
40 | data = data_plot,
41 | yval = "Survival",
42 | censor_show = TRUE,
43 | xticks = xticks, xlab = "Days", ylab = "Survival Probability",
44 | title = "tt",
45 | footnotes = "ff"
46 | )
47 |
48 | g_el <- h_decompose_gg(gg)
49 | grid::grid.newpage()
50 | grid.rect(gp = grid::gpar(lty = 1, col = "red", fill = "gray85", lwd = 5))
51 | grid::grid.draw(g_el$panel)
52 |
53 | grid::grid.newpage()
54 | grid.rect(gp = grid::gpar(lty = 1, col = "royalblue", fill = "gray85", lwd = 5))
55 | grid::grid.draw(with(g_el, cbind(ylab, yaxis)))
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/man/h_format_row.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/g_lineplot.R
3 | \name{h_format_row}
4 | \alias{h_format_row}
5 | \title{Helper function to format the optional \code{g_lineplot} table}
6 | \usage{
7 | h_format_row(x, format, labels = NULL)
8 | }
9 | \arguments{
10 | \item{x}{(named \code{list})\cr list of numerical values to be formatted and optionally labeled.
11 | Elements of \code{x} must be \code{numeric} vectors.}
12 |
13 | \item{format}{(named \code{character} or \code{NULL})\cr format patterns for \code{x}. Names of the \code{format} must
14 | match the names of \code{x}. This parameter is passed directly to the \code{rtables::format_rcell}
15 | function through the \code{format} parameter.}
16 |
17 | \item{labels}{(named \code{character} or \code{NULL})\cr optional labels for \code{x}. Names of the \code{labels} must
18 | match the names of \code{x}. When a label is not specified for an element of \code{x},
19 | then this function tries to use \code{label} or \code{names} (in this order) attribute of that element
20 | (depending on which one exists and it is not \code{NULL} or \code{NA} or \code{NaN}). If none of these attributes
21 | are attached to a given element of \code{x}, then the label is automatically generated.}
22 | }
23 | \value{
24 | A single row \code{data.frame} object.
25 | }
26 | \description{
27 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
28 | }
29 | \examples{
30 | mean_ci <- c(48, 51)
31 | x <- list(mean = 50, mean_ci = mean_ci)
32 | format <- c(mean = "xx.x", mean_ci = "(xx.xx, xx.xx)")
33 | labels <- c(mean = "My Mean")
34 | h_format_row(x, format, labels)
35 |
36 | attr(mean_ci, "label") <- "Mean 95\% CI"
37 | x <- list(mean = 50, mean_ci = mean_ci)
38 | h_format_row(x, format, labels)
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/man/h_grob_coxph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_km.R
3 | \name{h_grob_coxph}
4 | \alias{h_grob_coxph}
5 | \title{Helper function to create Cox-PH grobs}
6 | \usage{
7 | h_grob_coxph(
8 | ...,
9 | x = 0,
10 | y = 0,
11 | width = grid::unit(0.4, "npc"),
12 | ttheme = gridExtra::ttheme_default(padding = grid::unit(c(1, 0.5), "lines"), core =
13 | list(bg_params = list(fill = c("grey95", "grey90"), alpha = 0.5)))
14 | )
15 | }
16 | \arguments{
17 | \item{...}{arguments to pass to \code{\link[=h_tbl_coxph_pairwise]{h_tbl_coxph_pairwise()}}.}
18 |
19 | \item{x}{(\code{proportion})\cr a value between 0 and 1 specifying x-location.}
20 |
21 | \item{y}{(\code{proportion})\cr a value between 0 and 1 specifying y-location.}
22 |
23 | \item{width}{(\code{grid::unit})\cr width (as a unit) to use when printing the grob.}
24 |
25 | \item{ttheme}{(\code{list})\cr see \code{\link[gridExtra:tableGrob]{gridExtra::ttheme_default()}}.}
26 | }
27 | \value{
28 | A \code{grob} of a table containing statistics \code{HR}, \verb{XX\% CI} (\code{XX} taken from \code{control_coxph_pw}),
29 | and \code{p-value (log-rank)}.
30 | }
31 | \description{
32 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
33 |
34 | Grob of \code{rtable} output from \code{\link[=h_tbl_coxph_pairwise]{h_tbl_coxph_pairwise()}}
35 | }
36 | \examples{
37 | \donttest{
38 | library(dplyr)
39 | library(survival)
40 | library(grid)
41 |
42 | grid::grid.newpage()
43 | grid.rect(gp = grid::gpar(lty = 1, col = "pink", fill = "gray85", lwd = 1))
44 | data <- tern_ex_adtte \%>\%
45 | filter(PARAMCD == "OS") \%>\%
46 | mutate(is_event = CNSR == 0)
47 | tbl_grob <- h_grob_coxph(
48 | df = data,
49 | variables = list(tte = "AVAL", is_event = "is_event", arm = "ARMCD"),
50 | control_coxph_pw = control_coxph(conf_level = 0.9), x = 0.5, y = 0.5
51 | )
52 | grid::grid.draw(tbl_grob)
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/man/h_grob_median_surv.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_km.R
3 | \name{h_grob_median_surv}
4 | \alias{h_grob_median_surv}
5 | \title{Helper function to create survival estimation grobs}
6 | \usage{
7 | h_grob_median_surv(
8 | fit_km,
9 | armval = "All",
10 | x = 0.9,
11 | y = 0.9,
12 | width = grid::unit(0.3, "npc"),
13 | ttheme = gridExtra::ttheme_default()
14 | )
15 | }
16 | \arguments{
17 | \item{fit_km}{(\code{survfit})\cr result of \code{\link[survival:survfit]{survival::survfit()}}.}
18 |
19 | \item{armval}{(\code{string})\cr used as strata name when treatment arm variable only has one level. Default is \code{"All"}.}
20 |
21 | \item{x}{(\code{proportion})\cr a value between 0 and 1 specifying x-location.}
22 |
23 | \item{y}{(\code{proportion})\cr a value between 0 and 1 specifying y-location.}
24 |
25 | \item{width}{(\code{grid::unit})\cr width (as a unit) to use when printing the grob.}
26 |
27 | \item{ttheme}{(\code{list})\cr see \code{\link[gridExtra:tableGrob]{gridExtra::ttheme_default()}}.}
28 | }
29 | \value{
30 | A \code{grob} of a table containing statistics \code{N}, \code{Median}, and \verb{XX\% CI} (\code{XX} taken from \code{fit_km}).
31 | }
32 | \description{
33 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
34 |
35 | The survival fit is transformed in a grob containing a table with groups in
36 | rows characterized by N, median and 95\% confidence interval.
37 | }
38 | \examples{
39 | \donttest{
40 | library(dplyr)
41 | library(survival)
42 | library(grid)
43 |
44 | grid::grid.newpage()
45 | grid.rect(gp = grid::gpar(lty = 1, col = "pink", fill = "gray85", lwd = 1))
46 | tern_ex_adtte \%>\%
47 | filter(PARAMCD == "OS") \%>\%
48 | survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\%
49 | h_grob_median_surv() \%>\%
50 | grid::grid.draw()
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/man/h_grob_y_annot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_km.R
3 | \name{h_grob_y_annot}
4 | \alias{h_grob_y_annot}
5 | \title{Helper function to create grid object with y-axis annotation}
6 | \usage{
7 | h_grob_y_annot(ylab, yaxis)
8 | }
9 | \arguments{
10 | \item{ylab}{(\code{gtable})\cr the y-lab as a graphical object derived from a \code{ggplot}.}
11 |
12 | \item{yaxis}{(\code{gtable})\cr the y-axis as a graphical object derived from a \code{ggplot}.}
13 | }
14 | \value{
15 | A \code{gTree} object containing the y-axis annotation from a \code{ggplot}.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
19 |
20 | Build the y-axis annotation from a decomposed \code{ggplot}.
21 | }
22 | \examples{
23 | \donttest{
24 | library(dplyr)
25 | library(survival)
26 | library(grid)
27 |
28 | fit_km <- tern_ex_adtte \%>\%
29 | filter(PARAMCD == "OS") \%>\%
30 | survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .)
31 | data_plot <- h_data_plot(fit_km = fit_km)
32 | xticks <- h_xticks(data = data_plot)
33 | gg <- h_ggkm(
34 | data = data_plot,
35 | censor_show = TRUE,
36 | xticks = xticks, xlab = "Days", ylab = "Survival Probability",
37 | title = "title", footnotes = "footnotes", yval = "Survival"
38 | )
39 |
40 | g_el <- h_decompose_gg(gg)
41 |
42 | grid::grid.newpage()
43 | pvp <- grid::plotViewport(margins = c(5, 4, 2, 20))
44 | pushViewport(pvp)
45 | grid::grid.draw(h_grob_y_annot(ylab = g_el$ylab, yaxis = g_el$yaxis))
46 | grid.rect(gp = grid::gpar(lty = 1, col = "gray35", fill = NA))
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/man/h_pkparam_sort.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_pkparam_sort.R
3 | \name{h_pkparam_sort}
4 | \alias{h_pkparam_sort}
5 | \title{Sort pharmacokinetic data by \code{PARAM} variable}
6 | \usage{
7 | h_pkparam_sort(pk_data, key_var = "PARAMCD")
8 | }
9 | \arguments{
10 | \item{pk_data}{(\code{data.frame})\cr pharmacokinetic data frame.}
11 |
12 | \item{key_var}{(\code{string})\cr key variable used to merge pk_data and metadata created by \code{\link[=d_pkparam]{d_pkparam()}}.}
13 | }
14 | \value{
15 | A pharmacokinetic \code{data.frame} sorted by a \code{PARAM} variable.
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 | }
20 | \examples{
21 | library(dplyr)
22 |
23 | adpp <- tern_ex_adpp \%>\% mutate(PKPARAM = factor(paste0(PARAM, " (", AVALU, ")")))
24 | pk_ordered_data <- h_pkparam_sort(adpp)
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/man/h_ppmeans.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summarize_glm_count.R
3 | \name{h_ppmeans}
4 | \alias{h_ppmeans}
5 | \title{Function to return the estimated means using predicted probabilities}
6 | \usage{
7 | h_ppmeans(obj, .df_row, arm, conf_level)
8 | }
9 | \arguments{
10 | \item{obj}{(\code{glm.fit})\cr fitted model object used to derive the mean rate estimates in each treatment arm.}
11 |
12 | \item{.df_row}{(\code{data.frame})\cr dataset that includes all the variables that are called in \code{.var} and \code{variables}.}
13 |
14 | \item{arm}{(\code{string})\cr group variable, for which the covariate adjusted means of multiple groups will be
15 | summarized. Specifically, the first level of \code{arm} variable is taken as the reference group.}
16 |
17 | \item{conf_level}{(\code{proportion})\cr value used to derive the confidence interval for the rate.}
18 | }
19 | \value{
20 | \itemize{
21 | \item \code{h_ppmeans()} returns the estimated means.
22 | }
23 | }
24 | \description{
25 | For each arm level, the predicted mean rate is calculated using the fitted model object, with \code{newdata}
26 | set to the result of \code{stats::model.frame}, a reconstructed data or the original data, depending on the
27 | object formula (coming from the fit). The confidence interval is derived using the \code{conf_level} parameter.
28 | }
29 | \seealso{
30 | \code{\link[=summarize_glm_count]{summarize_glm_count()}}.
31 | }
32 |
--------------------------------------------------------------------------------
/man/h_prop_diff_test.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prop_diff_test.R
3 | \name{h_prop_diff_test}
4 | \alias{h_prop_diff_test}
5 | \alias{prop_chisq}
6 | \alias{prop_cmh}
7 | \alias{prop_schouten}
8 | \alias{prop_fisher}
9 | \title{Helper functions to test proportion differences}
10 | \usage{
11 | prop_chisq(tbl)
12 |
13 | prop_cmh(ary)
14 |
15 | prop_schouten(tbl)
16 |
17 | prop_fisher(tbl)
18 | }
19 | \arguments{
20 | \item{tbl}{(\code{matrix})\cr matrix with two groups in rows and the binary response (\code{TRUE}/\code{FALSE}) in columns.}
21 |
22 | \item{ary}{(\code{array}, 3 dimensions)\cr array with two groups in rows, the binary response
23 | (\code{TRUE}/\code{FALSE}) in columns, and the strata in the third dimension.}
24 | }
25 | \value{
26 | A p-value.
27 | }
28 | \description{
29 | Helper functions to implement various tests on the difference between two proportions.
30 | }
31 | \section{Functions}{
32 | \itemize{
33 | \item \code{prop_chisq()}: Performs Chi-Squared test. Internally calls \code{\link[stats:prop.test]{stats::prop.test()}}.
34 |
35 | \item \code{prop_cmh()}: Performs stratified Cochran-Mantel-Haenszel test. Internally calls
36 | \code{\link[stats:mantelhaen.test]{stats::mantelhaen.test()}}. Note that strata with less than two observations are automatically discarded.
37 |
38 | \item \code{prop_schouten()}: Performs the Chi-Squared test with Schouten correction.
39 |
40 | \item \code{prop_fisher()}: Performs the Fisher's exact test. Internally calls \code{\link[stats:fisher.test]{stats::fisher.test()}}.
41 |
42 | }}
43 | \seealso{
44 | \code{\link[=prop_diff_test]{prop_diff_test()}} for implementation of these helper functions.
45 |
46 | Schouten correction is based upon \insertCite{Schouten1980-kd;textual}{tern}.
47 | }
48 | \keyword{internal}
49 |
--------------------------------------------------------------------------------
/man/h_split_by_subgroups.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_survival_duration_subgroups.R
3 | \name{h_split_by_subgroups}
4 | \alias{h_split_by_subgroups}
5 | \title{Split data frame by subgroups}
6 | \usage{
7 | h_split_by_subgroups(data, subgroups, groups_lists = list())
8 | }
9 | \arguments{
10 | \item{data}{(\code{data.frame})\cr dataset to split.}
11 |
12 | \item{subgroups}{(\code{character})\cr names of factor variables from \code{data} used to create subsets.
13 | Unused levels not present in \code{data} are dropped. Note that the order in this vector
14 | determines the order in the downstream table.}
15 |
16 | \item{groups_lists}{(named \code{list} of \code{list})\cr optionally contains for each \code{subgroups} variable a
17 | list, which specifies the new group levels via the names and the
18 | levels that belong to it in the character vectors that are elements of the list.}
19 | }
20 | \value{
21 | A list with subset data (\code{df}) and metadata about the subset (\code{df_labels}).
22 | }
23 | \description{
24 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
25 |
26 | Split a data frame into a non-nested list of subsets.
27 | }
28 | \details{
29 | Main functionality is to prepare data for use in forest plot layouts.
30 | }
31 | \examples{
32 | df <- data.frame(
33 | x = c(1:5),
34 | y = factor(c("A", "B", "A", "B", "A"), levels = c("A", "B", "C")),
35 | z = factor(c("C", "C", "D", "D", "D"), levels = c("D", "C"))
36 | )
37 | formatters::var_labels(df) <- paste("label for", names(df))
38 |
39 | h_split_by_subgroups(
40 | data = df,
41 | subgroups = c("y", "z")
42 | )
43 |
44 | h_split_by_subgroups(
45 | data = df,
46 | subgroups = c("y", "z"),
47 | groups_lists = list(
48 | y = list("AB" = c("A", "B"), "C" = "C")
49 | )
50 | )
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/man/h_split_param.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{h_split_param}
4 | \alias{h_split_param}
5 | \title{Split parameters}
6 | \usage{
7 | h_split_param(param, value, f)
8 | }
9 | \arguments{
10 | \item{param}{(\code{vector})\cr the parameter to be split.}
11 |
12 | \item{value}{(\code{vector})\cr the value used to split.}
13 |
14 | \item{f}{(\code{list})\cr the reference to make the split.}
15 | }
16 | \value{
17 | A named \code{list} with the same element names as \code{f}, each containing the elements specified in \code{.stats}.
18 | }
19 | \description{
20 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
21 |
22 | It divides the data in the vector \code{param} into the groups defined by \code{f} based on specified \code{values}. It is relevant
23 | in \code{rtables} layers so as to distribute parameters \code{.stats} or' \code{.formats} into lists with items corresponding to
24 | specific analysis function.
25 | }
26 | \examples{
27 | f <- list(
28 | surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci"),
29 | surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval")
30 | )
31 |
32 | .stats <- c("pt_at_risk", "rate_diff")
33 | h_split_param(.stats, .stats, f = f)
34 |
35 | # $surv
36 | # [1] "pt_at_risk"
37 | #
38 | # $surv_diff
39 | # [1] "rate_diff"
40 |
41 | .formats <- c("pt_at_risk" = "xx", "event_free_rate" = "xxx")
42 | h_split_param(.formats, names(.formats), f = f)
43 |
44 | # $surv
45 | # pt_at_risk event_free_rate
46 | # "xx" "xxx"
47 | #
48 | # $surv_diff
49 | # NULL
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/man/h_tbl_median_surv.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_km.R
3 | \name{h_tbl_median_surv}
4 | \alias{h_tbl_median_surv}
5 | \title{Helper function for survival estimations}
6 | \usage{
7 | h_tbl_median_surv(fit_km, armval = "All")
8 | }
9 | \arguments{
10 | \item{fit_km}{(\code{survfit})\cr result of \code{\link[survival:survfit]{survival::survfit()}}.}
11 |
12 | \item{armval}{(\code{string})\cr used as strata name when treatment arm variable only has one level. Default is \code{"All"}.}
13 | }
14 | \value{
15 | A summary table with statistics \code{N}, \code{Median}, and \verb{XX\% CI} (\code{XX} taken from \code{fit_km}).
16 | }
17 | \description{
18 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
19 |
20 | Transform a survival fit to a table with groups in rows characterized by N, median and confidence interval.
21 | }
22 | \examples{
23 | library(dplyr)
24 | library(survival)
25 |
26 | adtte <- tern_ex_adtte \%>\% filter(PARAMCD == "OS")
27 | fit <- survfit(
28 | formula = Surv(AVAL, 1 - CNSR) ~ ARMCD,
29 | data = adtte
30 | )
31 | h_tbl_median_surv(fit_km = fit)
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/man/h_xticks.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/h_km.R
3 | \name{h_xticks}
4 | \alias{h_xticks}
5 | \title{Helper function to calculate x-tick positions}
6 | \usage{
7 | h_xticks(data, xticks = NULL, max_time = NULL)
8 | }
9 | \arguments{
10 | \item{data}{(\code{data.frame})\cr survival data as pre-processed by \code{h_data_plot}.}
11 |
12 | \item{xticks}{(\code{numeric} or \code{NULL})\cr numeric vector of tick positions or a single number with spacing
13 | between ticks on the x-axis. If \code{NULL} (default), \code{\link[labeling:extended]{labeling::extended()}} is used to determine
14 | optimal tick positions on the x-axis.}
15 |
16 | \item{max_time}{(\code{numeric(1)})\cr maximum value to show on x-axis. Only data values less than or up to
17 | this threshold value will be plotted (defaults to \code{NULL}).}
18 | }
19 | \value{
20 | A vector of positions to use for x-axis ticks on a \code{ggplot} object.
21 | }
22 | \description{
23 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
24 |
25 | Calculate the positions of ticks on the x-axis. However, if \code{xticks} already
26 | exists it is kept as is. It is based on the same function \code{ggplot2} relies on,
27 | and is required in the graphic and the patient-at-risk annotation table.
28 | }
29 | \examples{
30 | library(dplyr)
31 | library(survival)
32 |
33 | data <- tern_ex_adtte \%>\%
34 | filter(PARAMCD == "OS") \%>\%
35 | survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\%
36 | h_data_plot()
37 |
38 | h_xticks(data)
39 | h_xticks(data, xticks = seq(0, 3000, 500))
40 | h_xticks(data, xticks = 500)
41 | h_xticks(data, xticks = 500, max_time = 6000)
42 | h_xticks(data, xticks = c(0, 500), max_time = 300)
43 | h_xticks(data, xticks = 500, max_time = 300)
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/man/labels_or_names.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{labels_or_names}
4 | \alias{labels_or_names}
5 | \title{Labels or names of list elements}
6 | \usage{
7 | labels_or_names(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{list})\cr a list.}
11 | }
12 | \value{
13 | A \code{character} vector with the labels or names for the list elements.
14 | }
15 | \description{
16 | Internal helper function for working with nested statistic function results which typically
17 | don't have labels but names that we can use.
18 | }
19 | \keyword{internal}
20 |
--------------------------------------------------------------------------------
/man/labels_use_control.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_default_stats_formats_labels.R
3 | \name{labels_use_control}
4 | \alias{labels_use_control}
5 | \title{Update labels according to control specifications}
6 | \usage{
7 | labels_use_control(labels_default, control, labels_custom = NULL)
8 | }
9 | \arguments{
10 | \item{labels_default}{(named \code{character})\cr a named vector of statistic labels to modify
11 | according to the control specifications. Labels that are explicitly defined in \code{labels_custom} will
12 | not be affected.}
13 |
14 | \item{control}{(named \code{list})\cr list of control parameters to apply to adjust default labels.}
15 |
16 | \item{labels_custom}{(named \code{character})\cr named vector of labels that are customized by
17 | the user and should not be affected by \code{control}.}
18 | }
19 | \value{
20 | A named character vector of labels with control specifications applied to relevant labels.
21 | }
22 | \description{
23 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
24 |
25 | Given a list of statistic labels and and a list of control parameters, updates labels with a relevant
26 | control specification. For example, if control has element \code{conf_level} set to \code{0.9}, the default
27 | label for statistic \code{mean_ci} will be updated to \code{"Mean 90\% CI"}. Any labels that are supplied
28 | via \code{labels_custom} will not be updated regardless of \code{control}.
29 | }
30 | \examples{
31 | control <- list(conf_level = 0.80, quantiles = c(0.1, 0.83), test_mean = 0.57)
32 | get_labels_from_stats(c("mean_ci", "quantiles", "mean_pval")) \%>\%
33 | labels_use_control(control = control)
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/man/logistic_regression_cols.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/logistic_regression.R
3 | \name{logistic_regression_cols}
4 | \alias{logistic_regression_cols}
5 | \title{Logistic regression multivariate column layout function}
6 | \usage{
7 | logistic_regression_cols(lyt, conf_level = 0.95)
8 | }
9 | \arguments{
10 | \item{lyt}{(\code{PreDataTableLayouts})\cr layout that analyses will be added to.}
11 |
12 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
13 | }
14 | \value{
15 | A layout object suitable for passing to further layouting functions. Adding this
16 | function to an \code{rtable} layout will split the table into columns corresponding to
17 | statistics \code{df}, \code{estimate}, \code{std_error}, \code{odds_ratio}, \code{ci}, and \code{pvalue}.
18 | }
19 | \description{
20 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
21 |
22 | Layout-creating function which creates a multivariate column layout summarizing logistic
23 | regression results. This function is a wrapper for \code{\link[rtables:split_cols_by_multivar]{rtables::split_cols_by_multivar()}}.
24 | }
25 |
--------------------------------------------------------------------------------
/man/logistic_summary_by_flag.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/logistic_regression.R
3 | \name{logistic_summary_by_flag}
4 | \alias{logistic_summary_by_flag}
5 | \title{Logistic regression summary table}
6 | \usage{
7 | logistic_summary_by_flag(
8 | flag_var,
9 | na_str = default_na_str(),
10 | .indent_mods = NULL
11 | )
12 | }
13 | \arguments{
14 | \item{flag_var}{(\code{string})\cr variable name identifying which row should be used in this
15 | content function.}
16 |
17 | \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.}
18 |
19 | \item{.indent_mods}{(named \code{integer})\cr indent modifiers for the labels. Defaults to 0, which corresponds to the
20 | unmodified default behavior. Can be negative.}
21 | }
22 | \value{
23 | A content function.
24 | }
25 | \description{
26 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
27 |
28 | Constructor for content functions to be used in \code{\link[=summarize_logistic]{summarize_logistic()}} to summarize
29 | logistic regression results. This function is a wrapper for \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}}.
30 | }
31 |
--------------------------------------------------------------------------------
/man/make_names.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{make_names}
4 | \alias{make_names}
5 | \title{Make names without dots}
6 | \usage{
7 | make_names(nams)
8 | }
9 | \arguments{
10 | \item{nams}{(\code{character})\cr vector of original names.}
11 | }
12 | \value{
13 | A \code{character} \code{vector} of proper names, which does not use dots in contrast to \code{\link[=make.names]{make.names()}}.
14 | }
15 | \description{
16 | Make names without dots
17 | }
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/month2day.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{month2day}
4 | \alias{month2day}
5 | \title{Conversion of months to days}
6 | \usage{
7 | month2day(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric(1)})\cr time in months.}
11 | }
12 | \value{
13 | A \code{numeric} vector with the time in days.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 |
18 | Conversion of months to days. This is an approximative calculation because it
19 | considers each month as having an average of 30.4375 days.
20 | }
21 | \examples{
22 | x <- c(13.25, 8.15, 1, 2.834)
23 | month2day(x)
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/man/muffled_car_anova.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/cox_regression.R
3 | \name{muffled_car_anova}
4 | \alias{muffled_car_anova}
5 | \title{Muffled \code{car::Anova}}
6 | \usage{
7 | muffled_car_anova(mod, test_statistic)
8 | }
9 | \arguments{
10 | \item{mod}{(\code{coxph})\cr Cox regression model fitted by \code{\link[survival:coxph]{survival::coxph()}}.}
11 |
12 | \item{test_statistic}{(\code{string})\cr the method used for estimation of p.values; \code{wald} (default) or \code{likelihood}.}
13 | }
14 | \value{
15 | The output of \code{\link[car:Anova]{car::Anova()}}, with convergence message muffled.
16 | }
17 | \description{
18 | Applied on survival models, \code{\link[car:Anova]{car::Anova()}} signal that the \code{strata} terms is dropped from the model formula when
19 | present, this function deliberately muffles this message.
20 | }
21 | \keyword{internal}
22 |
--------------------------------------------------------------------------------
/man/n_available.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{n_available}
4 | \alias{n_available}
5 | \title{Number of available (non-missing entries) in a vector}
6 | \usage{
7 | n_available(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{vector})\cr vector in which to count non-missing values.}
11 | }
12 | \value{
13 | Number of non-missing values.
14 | }
15 | \description{
16 | Small utility function for better readability.
17 | }
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/range_noinf.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{range_noinf}
4 | \alias{range_noinf}
5 | \title{Re-implemented \code{range()} default S3 method for numerical objects}
6 | \usage{
7 | range_noinf(x, na.rm = FALSE, finite = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric})\cr a sequence of numbers for which the range is computed.}
11 |
12 | \item{na.rm}{(\code{flag})\cr flag indicating if \code{NA} should be omitted.}
13 |
14 | \item{finite}{(\code{flag})\cr flag indicating if non-finite elements should be removed.}
15 | }
16 | \value{
17 | A 2-element vector of class \code{numeric}.
18 | }
19 | \description{
20 | This function returns \code{c(NA, NA)} instead of \code{c(-Inf, Inf)} for zero-length data
21 | without any warnings.
22 | }
23 | \keyword{internal}
24 |
--------------------------------------------------------------------------------
/man/reapply_varlabels.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{reapply_varlabels}
4 | \alias{reapply_varlabels}
5 | \title{Reapply variable labels}
6 | \usage{
7 | reapply_varlabels(x, varlabels, ...)
8 | }
9 | \arguments{
10 | \item{x}{(\code{vector})\cr vector of elements that needs new labels.}
11 |
12 | \item{varlabels}{(\code{character})\cr vector of labels for \code{x}.}
13 |
14 | \item{...}{further parameters to be added to the list.}
15 | }
16 | \value{
17 | \code{x} with variable labels reapplied.
18 | }
19 | \description{
20 | This is a helper function that is used in tests.
21 | }
22 |
--------------------------------------------------------------------------------
/man/rtable2gg.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_ggplot.R
3 | \name{rtable2gg}
4 | \alias{rtable2gg}
5 | \title{Convert \code{rtable} objects to \code{ggplot} objects}
6 | \usage{
7 | rtable2gg(tbl, fontsize = 12, colwidths = NULL, lbl_col_padding = 0)
8 | }
9 | \arguments{
10 | \item{tbl}{(\code{VTableTree})\cr \code{rtables} table object.}
11 |
12 | \item{fontsize}{(\code{numeric(1)})\cr font size.}
13 |
14 | \item{colwidths}{(\code{numeric} or \code{NULL})\cr a vector of column widths. Each element's position in
15 | \code{colwidths} corresponds to the column of \code{tbl} in the same position. If \code{NULL}, column widths
16 | are calculated according to maximum number of characters per column.}
17 |
18 | \item{lbl_col_padding}{(\code{numeric})\cr additional padding to use when calculating spacing between
19 | the first (label) column and the second column of \code{tbl}. If \code{colwidths} is specified,
20 | the width of the first column becomes \code{colwidths[1] + lbl_col_padding}. Defaults to 0.}
21 | }
22 | \value{
23 | A \code{ggplot} object.
24 | }
25 | \description{
26 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
27 |
28 | Given a \code{\link[rtables:rtable]{rtables::rtable()}} object, performs basic conversion to a \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} object built using
29 | functions from the \code{ggplot2} package. Any table titles and/or footnotes are ignored.
30 | }
31 | \examples{
32 | dta <- data.frame(
33 | ARM = rep(LETTERS[1:3], rep(6, 3)),
34 | AVISIT = rep(paste0("V", 1:3), 6),
35 | AVAL = c(9:1, rep(NA, 9))
36 | )
37 |
38 | lyt <- basic_table() \%>\%
39 | split_cols_by(var = "ARM") \%>\%
40 | split_rows_by(var = "AVISIT") \%>\%
41 | analyze_vars(vars = "AVAL")
42 |
43 | tbl <- build_table(lyt, df = dta)
44 |
45 | rtable2gg(tbl)
46 |
47 | rtable2gg(tbl, fontsize = 15, colwidths = c(2, 1, 1, 1))
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/man/s_bland_altman.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/bland_altman.R
3 | \name{s_bland_altman}
4 | \alias{s_bland_altman}
5 | \title{Bland-Altman analysis}
6 | \usage{
7 | s_bland_altman(x, y, conf_level = 0.95)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric})\cr vector of numbers we want to analyze.}
11 |
12 | \item{y}{(\code{numeric})\cr vector of numbers we want to analyze, to be compared with \code{x}.}
13 |
14 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
15 | }
16 | \value{
17 | A named list of the following elements:
18 | \itemize{
19 | \item \code{df}
20 | \item \code{difference_mean}
21 | \item \code{ci_mean}
22 | \item \code{difference_sd}
23 | \item \code{difference_se}
24 | \item \code{upper_agreement_limit}
25 | \item \code{lower_agreement_limit}
26 | \item \code{agreement_limit_se}
27 | \item \code{upper_agreement_limit_ci}
28 | \item \code{lower_agreement_limit_ci}
29 | \item \code{t_value}
30 | \item \code{n}
31 | }
32 | }
33 | \description{
34 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
35 |
36 | Statistics function that uses the Bland-Altman method to assess the agreement between two numerical vectors
37 | and calculates a variety of statistics.
38 | }
39 | \examples{
40 | x <- seq(1, 60, 5)
41 | y <- seq(5, 50, 4)
42 |
43 | s_bland_altman(x, y, conf_level = 0.9)
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/man/sas_na.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/missing_data.R
3 | \name{sas_na}
4 | \alias{sas_na}
5 | \title{Convert strings to \code{NA}}
6 | \usage{
7 | sas_na(x, empty = TRUE, whitespaces = TRUE)
8 | }
9 | \arguments{
10 | \item{x}{(\code{factor} or \code{character})\cr values for which any missing values should be substituted.}
11 |
12 | \item{empty}{(\code{flag})\cr if \code{TRUE}, empty strings get replaced by \code{NA}.}
13 |
14 | \item{whitespaces}{(\code{flag})\cr if \code{TRUE}, strings made from only whitespaces get replaced with \code{NA}.}
15 | }
16 | \value{
17 | \code{x} with \code{""} and/or whitespace-only values substituted by \code{NA}, depending on the values of
18 | \code{empty} and \code{whitespaces}.
19 | }
20 | \description{
21 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
22 |
23 | SAS imports missing data as empty strings or strings with whitespaces only. This helper function can be used to
24 | convert these values to \code{NA}s.
25 | }
26 | \examples{
27 | sas_na(c("1", "", " ", " ", "b"))
28 | sas_na(factor(c("", " ", "b")))
29 |
30 | is.na(sas_na(c("1", "", " ", " ", "b")))
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/man/stack_grobs.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_grid.R
3 | \name{stack_grobs}
4 | \alias{stack_grobs}
5 | \title{Stack multiple grobs}
6 | \usage{
7 | stack_grobs(
8 | ...,
9 | grobs = list(...),
10 | padding = grid::unit(2, "line"),
11 | vp = NULL,
12 | gp = NULL,
13 | name = NULL
14 | )
15 | }
16 | \arguments{
17 | \item{...}{grobs.}
18 |
19 | \item{grobs}{(\code{list} of \code{grob})\cr a list of grobs.}
20 |
21 | \item{padding}{(\code{grid::unit})\cr unit of length 1, space between each grob.}
22 |
23 | \item{vp}{(\code{viewport} or \code{NULL})\cr a \code{\link[=viewport]{viewport()}} object (or \code{NULL}).}
24 |
25 | \item{gp}{(\code{gpar})\cr a \code{\link[=gpar]{gpar()}} object.}
26 |
27 | \item{name}{(\code{string})\cr a character identifier for the grob.}
28 | }
29 | \value{
30 | A \code{grob}.
31 | }
32 | \description{
33 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
34 |
35 | Stack grobs as a new grob with 1 column and multiple rows layout.
36 | }
37 | \examples{
38 | library(grid)
39 |
40 | g1 <- circleGrob(gp = gpar(col = "blue"))
41 | g2 <- circleGrob(gp = gpar(col = "red"))
42 | g3 <- textGrob("TEST TEXT")
43 | grid.newpage()
44 | grid.draw(stack_grobs(g1, g2, g3))
45 |
46 | showViewport()
47 |
48 | grid.newpage()
49 | pushViewport(viewport(layout = grid.layout(1, 2)))
50 | vp1 <- viewport(layout.pos.row = 1, layout.pos.col = 2)
51 | grid.draw(stack_grobs(g1, g2, g3, vp = vp1, name = "test"))
52 |
53 | showViewport()
54 | grid.ls(grobs = TRUE, viewports = TRUE, print = FALSE)
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/man/stat_mean_ci.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/stat.R
3 | \name{stat_mean_ci}
4 | \alias{stat_mean_ci}
5 | \title{Confidence interval for mean}
6 | \usage{
7 | stat_mean_ci(
8 | x,
9 | conf_level = 0.95,
10 | na.rm = TRUE,
11 | n_min = 2,
12 | gg_helper = TRUE,
13 | geom_mean = FALSE
14 | )
15 | }
16 | \arguments{
17 | \item{x}{(\code{numeric})\cr vector of numbers we want to analyze.}
18 |
19 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
20 |
21 | \item{na.rm}{(\code{flag})\cr whether \code{NA} values should be removed from \code{x} prior to analysis.}
22 |
23 | \item{n_min}{(\code{numeric(1)})\cr a minimum number of non-missing \code{x} to estimate the confidence interval for mean.}
24 |
25 | \item{gg_helper}{(\code{flag})\cr whether output should be aligned for use with \code{ggplot}s.}
26 |
27 | \item{geom_mean}{(\code{flag})\cr whether the geometric mean should be calculated.}
28 | }
29 | \value{
30 | A named \code{vector} of values \code{mean_ci_lwr} and \code{mean_ci_upr}.
31 | }
32 | \description{
33 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
34 |
35 | Convenient function for calculating the mean confidence interval. It calculates the arithmetic as well as the
36 | geometric mean. It can be used as a \code{ggplot} helper function for plotting.
37 | }
38 | \examples{
39 | stat_mean_ci(sample(10), gg_helper = FALSE)
40 |
41 | p <- ggplot2::ggplot(mtcars, ggplot2::aes(cyl, mpg)) +
42 | ggplot2::geom_point()
43 |
44 | p + ggplot2::stat_summary(
45 | fun.data = stat_mean_ci,
46 | geom = "errorbar"
47 | )
48 |
49 | p + ggplot2::stat_summary(
50 | fun.data = stat_mean_ci,
51 | fun.args = list(conf_level = 0.5),
52 | geom = "errorbar"
53 | )
54 |
55 | p + ggplot2::stat_summary(
56 | fun.data = stat_mean_ci,
57 | fun.args = list(conf_level = 0.5, geom_mean = TRUE),
58 | geom = "errorbar"
59 | )
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/man/stat_mean_pval.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/stat.R
3 | \name{stat_mean_pval}
4 | \alias{stat_mean_pval}
5 | \title{p-Value of the mean}
6 | \usage{
7 | stat_mean_pval(x, na.rm = TRUE, n_min = 2, test_mean = 0)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric})\cr vector of numbers we want to analyze.}
11 |
12 | \item{na.rm}{(\code{flag})\cr whether \code{NA} values should be removed from \code{x} prior to analysis.}
13 |
14 | \item{n_min}{(\code{numeric(1)})\cr a minimum number of non-missing \code{x} to estimate the p-value of the mean.}
15 |
16 | \item{test_mean}{(\code{numeric(1)})\cr mean value to test under the null hypothesis.}
17 | }
18 | \value{
19 | A p-value.
20 | }
21 | \description{
22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
23 |
24 | Convenient function for calculating the two-sided p-value of the mean.
25 | }
26 | \examples{
27 | stat_mean_pval(sample(10))
28 |
29 | stat_mean_pval(rnorm(10), test_mean = 0.5)
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/man/stat_median_ci.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/stat.R
3 | \name{stat_median_ci}
4 | \alias{stat_median_ci}
5 | \title{Confidence interval for median}
6 | \usage{
7 | stat_median_ci(x, conf_level = 0.95, na.rm = TRUE, gg_helper = TRUE)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric})\cr vector of numbers we want to analyze.}
11 |
12 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
13 |
14 | \item{na.rm}{(\code{flag})\cr whether \code{NA} values should be removed from \code{x} prior to analysis.}
15 |
16 | \item{gg_helper}{(\code{flag})\cr whether output should be aligned for use with \code{ggplot}s.}
17 | }
18 | \value{
19 | A named \code{vector} of values \code{median_ci_lwr} and \code{median_ci_upr}.
20 | }
21 | \description{
22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
23 |
24 | Convenient function for calculating the median confidence interval. It can be used as a \code{ggplot} helper
25 | function for plotting.
26 | }
27 | \details{
28 | This function was adapted from \verb{DescTools/versions/0.99.35/source}
29 | }
30 | \examples{
31 | stat_median_ci(sample(10), gg_helper = FALSE)
32 |
33 | p <- ggplot2::ggplot(mtcars, ggplot2::aes(cyl, mpg)) +
34 | ggplot2::geom_point()
35 | p + ggplot2::stat_summary(
36 | fun.data = stat_median_ci,
37 | geom = "errorbar"
38 | )
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/man/strata_normal_quantile.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/estimate_proportion.R
3 | \name{strata_normal_quantile}
4 | \alias{strata_normal_quantile}
5 | \title{Helper function for the estimation of stratified quantiles}
6 | \usage{
7 | strata_normal_quantile(vars, weights, conf_level)
8 | }
9 | \arguments{
10 | \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.}
11 |
12 | \item{weights}{(\code{numeric} or \code{NULL})\cr weights for each level of the strata. If \code{NULL}, they are
13 | estimated using the iterative algorithm proposed in \insertCite{Yan2010-jt;textual}{tern} that
14 | minimizes the weighted squared length of the confidence interval.}
15 |
16 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
17 | }
18 | \value{
19 | Stratified quantile.
20 | }
21 | \description{
22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
23 |
24 | This function wraps the estimation of stratified percentiles when we assume
25 | the approximation for large numbers. This is necessary only in the case
26 | proportions for each strata are unequal.
27 | }
28 | \examples{
29 | strata_data <- table(data.frame(
30 | "f1" = sample(c(TRUE, FALSE), 100, TRUE),
31 | "f2" = sample(c("x", "y", "z"), 100, TRUE),
32 | stringsAsFactors = TRUE
33 | ))
34 | ns <- colSums(strata_data)
35 | ests <- strata_data["TRUE", ] / ns
36 | vars <- ests * (1 - ests) / ns
37 | weights <- rep(1 / length(ns), length(ns))
38 |
39 | strata_normal_quantile(vars, weights, 0.95)
40 |
41 | }
42 | \seealso{
43 | \code{\link[=prop_strat_wilson]{prop_strat_wilson()}}
44 | }
45 |
--------------------------------------------------------------------------------
/man/study_arm.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{study_arm}
4 | \alias{study_arm}
5 | \title{Indicate study arm variable in formula}
6 | \usage{
7 | study_arm(x)
8 | }
9 | \arguments{
10 | \item{x}{arm information}
11 | }
12 | \value{
13 | \code{x}
14 | }
15 | \description{
16 | We use \code{study_arm} to indicate the study arm variable in \code{tern} formulas.
17 | }
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/summarize_functions.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summarize_functions.R
3 | \name{summarize_functions}
4 | \alias{summarize_functions}
5 | \title{Summarize functions}
6 | \description{
7 | These functions are wrappers for \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}}, applying corresponding \code{tern} content functions
8 | to add summary rows to a given table layout:
9 | }
10 | \details{
11 | \itemize{
12 | \item \code{\link[=add_rowcounts]{add_rowcounts()}}
13 | \item \code{\link[=estimate_multinomial_response]{estimate_multinomial_response()}} (with \code{\link[rtables:analyze]{rtables::analyze()}})
14 | \item \code{\link[=logistic_summary_by_flag]{logistic_summary_by_flag()}}
15 | \item \code{\link[=summarize_num_patients]{summarize_num_patients()}}
16 | \item \code{\link[=summarize_occurrences]{summarize_occurrences()}}
17 | \item \code{\link[=summarize_occurrences_by_grade]{summarize_occurrences_by_grade()}}
18 | \item \code{\link[=summarize_patients_events_in_cols]{summarize_patients_events_in_cols()}}
19 | \item \code{\link[=summarize_patients_exposure_in_cols]{summarize_patients_exposure_in_cols()}}
20 | }
21 |
22 | Additionally, the \code{\link[=summarize_coxreg]{summarize_coxreg()}} function utilizes \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}}
23 | (in combination with several other \code{rtables} functions like \code{\link[rtables:analyze_colvars]{rtables::analyze_colvars()}}) to
24 | output a Cox regression summary table.
25 | }
26 | \seealso{
27 | \itemize{
28 | \item \link{analyze_functions} for functions which are wrappers for \code{\link[rtables:analyze]{rtables::analyze()}}.
29 | \item \link{analyze_colvars_functions} for functions that are wrappers for \code{\link[rtables:analyze_colvars]{rtables::analyze_colvars()}}.
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/man/tern-package.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/package.R
3 | \docType{package}
4 | \name{tern-package}
5 | \alias{tern}
6 | \alias{tern-package}
7 | \title{tern Package}
8 | \description{
9 | Package to create tables, listings and graphs to analyze clinical trials data.
10 | }
11 | \seealso{
12 | Useful links:
13 | \itemize{
14 | \item \url{https://insightsengineering.github.io/tern/}
15 | \item \url{https://github.com/insightsengineering/tern/}
16 | \item Report bugs at \url{https://github.com/insightsengineering/tern/issues}
17 | }
18 |
19 | }
20 | \author{
21 | \strong{Maintainer}: Joe Zhu \email{joe.zhu@roche.com} (\href{https://orcid.org/0000-0001-7566-2787}{ORCID})
22 |
23 | Authors:
24 | \itemize{
25 | \item Daniel Sabanés Bové \email{daniel.sabanes_bove@roche.com}
26 | \item Jana Stoilova \email{jana.stoilova@roche.com}
27 | \item Davide Garolini \email{davide.garolini@roche.com} (\href{https://orcid.org/0000-0002-1445-1369}{ORCID})
28 | \item Emily de la Rua \email{emily.de_la_rua@contractors.roche.com} (\href{https://orcid.org/0009-0000-8738-5561}{ORCID})
29 | \item Abinaya Yogasekaram \email{abinaya.yogasekaram@contractors.roche.com} (\href{https://orcid.org/0009-0005-2083-1105}{ORCID})
30 | \item Heng Wang \email{wang.heng@gene.com}
31 | \item Francois Collin
32 | \item Adrian Waddell \email{adrian.waddell@gene.com}
33 | \item Pawel Rucki \email{pawel.rucki@roche.com}
34 | \item Chendi Liao \email{chendi.liao@roche.com}
35 | \item Jennifer Li \email{li.jing@gene.com}
36 | }
37 |
38 | Other contributors:
39 | \itemize{
40 | \item F. Hoffmann-La Roche AG [copyright holder, funder]
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/man/tidy.step.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/g_step.R
3 | \name{tidy.step}
4 | \alias{tidy.step}
5 | \title{Custom tidy method for STEP results}
6 | \usage{
7 | \method{tidy}{step}(x, ...)
8 | }
9 | \arguments{
10 | \item{x}{(\code{matrix})\cr results from \code{\link[=fit_survival_step]{fit_survival_step()}}.}
11 |
12 | \item{...}{not used.}
13 | }
14 | \value{
15 | A \code{tibble} with one row per STEP subgroup. The estimates and CIs are on the HR or OR scale,
16 | respectively. Additional attributes carry metadata also used for plotting.
17 | }
18 | \description{
19 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
20 |
21 | Tidy the STEP results into a \code{tibble} format ready for plotting.
22 | }
23 | \examples{
24 | library(survival)
25 | lung$sex <- factor(lung$sex)
26 | vars <- list(
27 | time = "time",
28 | event = "status",
29 | arm = "sex",
30 | biomarker = "age"
31 | )
32 | step_matrix <- fit_survival_step(
33 | variables = vars,
34 | data = lung,
35 | control = c(control_coxph(), control_step(num_points = 10, degree = 2))
36 | )
37 | broom::tidy(step_matrix)
38 |
39 | }
40 | \seealso{
41 | \code{\link[=g_step]{g_step()}} which consumes the result from this function.
42 | }
43 |
--------------------------------------------------------------------------------
/man/to_n.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{to_n}
4 | \alias{to_n}
5 | \title{Replicate entries of a vector if required}
6 | \usage{
7 | to_n(x, n)
8 | }
9 | \arguments{
10 | \item{x}{(\code{numeric})\cr vector of numbers we want to analyze.}
11 |
12 | \item{n}{(\code{integer(1)})\cr number of entries that are needed.}
13 | }
14 | \value{
15 | \code{x} if it has the required length already or is \code{NULL},
16 | otherwise if it is scalar the replicated version of it with \code{n} entries.
17 | }
18 | \description{
19 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
20 |
21 | Replicate entries of a vector if required.
22 | }
23 | \note{
24 | This function will fail if \code{x} is not of length \code{n} and/or is not a scalar.
25 | }
26 |
--------------------------------------------------------------------------------
/man/univariate.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/coxph.R
3 | \name{univariate}
4 | \alias{univariate}
5 | \title{Univariate formula special term}
6 | \usage{
7 | univariate(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{character})\cr a vector of variable names separated by commas.}
11 | }
12 | \value{
13 | When used within a model formula, produces univariate models for each variable provided.
14 | }
15 | \description{
16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
17 |
18 | The special term \code{univariate} indicate that the model should be fitted individually for
19 | every variable included in univariate.
20 | }
21 | \details{
22 | If provided alongside with pairwise specification, the model
23 | \code{y ~ ARM + univariate(SEX, AGE, RACE)} lead to the study and comparison of the models
24 | \itemize{
25 | \item \code{y ~ ARM}
26 | \item \code{y ~ ARM + SEX}
27 | \item \code{y ~ ARM + AGE}
28 | \item \code{y ~ ARM + RACE}
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/man/unlist_and_blank_na.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils_rtables.R
3 | \name{unlist_and_blank_na}
4 | \alias{unlist_and_blank_na}
5 | \title{Blank for missing input}
6 | \usage{
7 | unlist_and_blank_na(x)
8 | }
9 | \arguments{
10 | \item{x}{(\code{vector})\cr input for a cell.}
11 | }
12 | \value{
13 | An empty \code{character} vector if all entries in \code{x} are missing (\code{NA}), otherwise
14 | the unlisted version of \code{x}.
15 | }
16 | \description{
17 | Helper function to use in tabulating model results.
18 | }
19 | \keyword{internal}
20 |
--------------------------------------------------------------------------------
/man/update_weights_strat_wilson.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/estimate_proportion.R
3 | \name{update_weights_strat_wilson}
4 | \alias{update_weights_strat_wilson}
5 | \title{Helper function for the estimation of weights for \code{prop_strat_wilson()}}
6 | \usage{
7 | update_weights_strat_wilson(
8 | vars,
9 | strata_qnorm,
10 | initial_weights,
11 | n_per_strata,
12 | max_iterations = 50,
13 | conf_level = 0.95,
14 | tol = 0.001
15 | )
16 | }
17 | \arguments{
18 | \item{vars}{(\code{numeric})\cr normalized proportions for each strata.}
19 |
20 | \item{strata_qnorm}{(\code{numeric(1)})\cr initial estimation with identical weights of the quantiles.}
21 |
22 | \item{initial_weights}{(\code{numeric})\cr initial weights used to calculate \code{strata_qnorm}. This can
23 | be optimized in the future if we need to estimate better initial weights.}
24 |
25 | \item{n_per_strata}{(\code{numeric})\cr number of elements in each strata.}
26 |
27 | \item{max_iterations}{(\code{integer(1)})\cr maximum number of iterations to be tried. Convergence is always checked.}
28 |
29 | \item{conf_level}{(\code{proportion})\cr confidence level of the interval.}
30 |
31 | \item{tol}{(\code{numeric(1)})\cr tolerance threshold for convergence.}
32 | }
33 | \value{
34 | A \code{list} of 3 elements: \code{n_it}, \code{weights}, and \code{diff_v}.
35 | }
36 | \description{
37 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
38 |
39 | This function wraps the iteration procedure that allows you to estimate
40 | the weights for each proportional strata. This assumes to minimize the
41 | weighted squared length of the confidence interval.
42 | }
43 | \examples{
44 | vs <- c(0.011, 0.013, 0.012, 0.014, 0.017, 0.018)
45 | sq <- 0.674
46 | ws <- rep(1 / length(vs), length(vs))
47 | ns <- c(22, 18, 17, 17, 14, 12)
48 |
49 | update_weights_strat_wilson(vs, sq, ws, ns, 100, 0.95, 0.001)
50 |
51 | }
52 | \seealso{
53 | For references and details see \code{\link[=prop_strat_wilson]{prop_strat_wilson()}}.
54 | }
55 |
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insightsengineering/tern/a03830469b99d061100c681e87c2915e83d0c94e/pkgdown/favicon/favicon.ico
--------------------------------------------------------------------------------
/revdep/.gitignore:
--------------------------------------------------------------------------------
1 | checks
2 | library
3 | checks.noindex
4 | library.noindex
5 | cloud.noindex
6 | data.sqlite
7 | *.html
8 |
--------------------------------------------------------------------------------
/tern.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 | ProjectId: dff38f7e-0b7b-4359-b99c-9fd05b04d239
3 |
4 | RestoreWorkspace: Default
5 | SaveWorkspace: Default
6 | AlwaysSaveHistory: Default
7 |
8 | EnableCodeIndexing: Yes
9 | UseSpacesForTab: Yes
10 | NumSpacesForTab: 2
11 | Encoding: UTF-8
12 |
13 | RnwWeave: Sweave
14 | LaTeX: pdfLaTeX
15 |
16 | AutoAppendNewline: Yes
17 | StripTrailingWhitespace: Yes
18 | LineEndingConversion: Posix
19 |
20 | BuildType: Package
21 | PackageUseDevtools: Yes
22 | PackageInstallArgs: --no-multiarch --with-keep.source
23 | PackageCheckArgs: --as-cran
24 | PackageRoxygenize: rd,collate,namespace
25 |
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | pkg_name <- "tern"
2 | library(testthat)
3 | test_check(pkg_name, reporter = ParallelProgressReporter$new())
4 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/abnormal_by_marked.md:
--------------------------------------------------------------------------------
1 | # s_count_abnormal_by_marked works as expected
2 |
3 | Code
4 | res
5 | Output
6 | $count_fraction
7 | $count_fraction$`Single, not last`
8 | [1] 0 0
9 |
10 | $count_fraction$`Last or replicated`
11 | [1] 3.00000000 0.04347826
12 |
13 | $count_fraction$`Any Abnormality`
14 | [1] 3.00000000 0.04347826
15 |
16 |
17 |
18 | ---
19 |
20 | Code
21 | res
22 | Output
23 | $count_fraction
24 | $count_fraction$`Single, not last`
25 | [1] 1.00000000 0.01449275
26 |
27 | $count_fraction$`Last or replicated`
28 | [1] 5.00000000 0.07246377
29 |
30 | $count_fraction$`Any Abnormality`
31 | [1] 6.00000000 0.08695652
32 |
33 |
34 |
35 | # count_abnormal_by_marked works as expected
36 |
37 | Code
38 | res
39 | Output
40 | ARM A ARM B ARM C
41 | ———————————————————————————————————————————————————————
42 | CRP (n) 69 73 58
43 | Low
44 | Single, not last 0 1 (1.4%) 0
45 | Last or replicated 3 (4.3%) 2 (2.7%) 3 (5.2%)
46 | Any Abnormality 3 (4.3%) 3 (4.1%) 3 (5.2%)
47 | High
48 | Single, not last 1 (1.4%) 0 0
49 | Last or replicated 5 (7.2%) 5 (6.8%) 4 (6.9%)
50 | Any Abnormality 6 (8.7%) 5 (6.8%) 4 (6.9%)
51 |
52 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/abnormal_by_worst_grade.md:
--------------------------------------------------------------------------------
1 | # s_count_abnormal_by_worst_grade works as expected
2 |
3 | Code
4 | res
5 | Output
6 | $count_fraction
7 | $count_fraction$`1`
8 | count fraction
9 | 12.000000 0.173913
10 | attr(,"label")
11 | [1] "1"
12 |
13 | $count_fraction$`2`
14 | count fraction
15 | 9.0000000 0.1304348
16 | attr(,"label")
17 | [1] "2"
18 |
19 | $count_fraction$`3`
20 | count fraction
21 | 6.00000000 0.08695652
22 | attr(,"label")
23 | [1] "3"
24 |
25 | $count_fraction$`4`
26 | count fraction
27 | 7.0000000 0.1014493
28 | attr(,"label")
29 | [1] "4"
30 |
31 | $count_fraction$Any
32 | count fraction
33 | 34.0000000 0.4927536
34 | attr(,"label")
35 | [1] "Any"
36 |
37 |
38 |
39 | # count_abnormal_by_worst_grade works as expected
40 |
41 | Code
42 | res
43 | Output
44 | ARM A ARM B ARM C
45 | ———————————————————————————————————————————————————————————————————
46 | Immunoglobulin A Measurement
47 | HIGH
48 | 1 7 (10.1%) 7 (9.6%) 6 (10.3%)
49 | 2 8 (11.6%) 6 (8.2%) 8 (13.8%)
50 | 3 7 (10.1%) 5 (6.8%) 9 (15.5%)
51 | 4 6 (8.7%) 2 (2.7%) 3 (5.2%)
52 | Any 28 (40.6%) 20 (27.4%) 26 (44.8%)
53 |
54 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/bland-altman.md:
--------------------------------------------------------------------------------
1 | # s_bland_altman works with default settings
2 |
3 | Code
4 | res
5 | Output
6 | $df
7 | average difference
8 | 1 0.14626178 -1.5454312
9 | 2 0.48288981 -0.5984930
10 | 3 -0.38053181 -0.9101936
11 | 4 -0.19703545 3.5846325
12 | 5 0.47466676 -0.2903180
13 | 6 -0.43829856 -0.7643396
14 | 7 0.16581677 0.6432246
15 | 8 -0.36621383 2.2090771
16 | 9 0.04881564 1.0539314
17 | 10 0.05627658 -0.7233299
18 | 11 1.43523036 0.1531016
19 | 12 0.14352775 0.4926310
20 | 13 -0.11678449 -1.0089122
21 | 14 -1.13425246 -2.1608949
22 | 15 -0.12606432 2.5019905
23 | 16 -0.22996409 0.3700609
24 | 17 -0.20524011 0.3780997
25 | 18 0.44226140 1.0031496
26 | 19 0.96062329 -0.2788042
27 | 20 0.67853853 -0.1692744
28 |
29 | $difference_mean
30 | [1] 0.1969954
31 |
32 | $ci_mean
33 | [1] -0.3414723 0.7354631
34 |
35 | $difference_sd
36 | [1] 1.392664
37 |
38 | $difference_se
39 | [1] 0.3114091
40 |
41 | $upper_agreement_limit
42 | [1] 2.487724
43 |
44 | $lower_agreement_limit
45 | [1] -2.093733
46 |
47 | $agreement_limit_se
48 | [1] 0.5393764
49 |
50 | $upper_agreement_limit_ci
51 | [1] 1.555070 3.420377
52 |
53 | $lower_agreement_limit_ci
54 | [1] -3.026386 -1.161079
55 |
56 | $t_value
57 | [1] 1.729133
58 |
59 | $n
60 | [1] 20
61 |
62 |
63 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/control_logistic.md:
--------------------------------------------------------------------------------
1 | # control_logistic works with customized parameters
2 |
3 | Code
4 | res
5 | Output
6 | $response_definition
7 | [1] "response == 'bla'"
8 |
9 | $conf_level
10 | [1] 0.9
11 |
12 |
13 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/control_step.md:
--------------------------------------------------------------------------------
1 | # control_step works with customized parameters
2 |
3 | Code
4 | res
5 | Output
6 | $use_percentile
7 | [1] FALSE
8 |
9 | $bandwidth
10 | [1] 2.25
11 |
12 | $degree
13 | [1] 0
14 |
15 | $num_points
16 | [1] 39
17 |
18 |
19 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/control_survival.md:
--------------------------------------------------------------------------------
1 | # control_coxph works with customized parameters
2 |
3 | Code
4 | res
5 | Output
6 | $pval_method
7 | [1] "wald"
8 |
9 | $ties
10 | [1] "breslow"
11 |
12 | $conf_level
13 | [1] 0.8
14 |
15 |
16 | # control_surv_time works with customized parameters
17 |
18 | Code
19 | res
20 | Output
21 | $conf_level
22 | [1] 0.8
23 |
24 | $conf_type
25 | [1] "log-log"
26 |
27 | $quantiles
28 | [1] 0.3 0.8
29 |
30 |
31 | # control_surv_timepoint works with customized parameters
32 |
33 | Code
34 | res
35 | Output
36 | $conf_level
37 | [1] 0.8
38 |
39 | $conf_type
40 | [1] "log-log"
41 |
42 |
43 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/count_missed_doses.md:
--------------------------------------------------------------------------------
1 | # d_count_missed_doses works as expected
2 |
3 | Code
4 | res
5 | Output
6 | [1] "At least 1 missed dose" "At least 5 missed doses"
7 |
8 | # s_count_missed_doses works as expected
9 |
10 | Code
11 | res
12 | Output
13 | $n
14 | [1] 8
15 |
16 | $count_fraction
17 | $count_fraction$`2`
18 | count fraction
19 | 4.0 0.4
20 | attr(,"label")
21 | [1] "At least 2 missed doses"
22 |
23 | $count_fraction$`5`
24 | count fraction
25 | 0 0
26 | attr(,"label")
27 | [1] "At least 5 missed doses"
28 |
29 |
30 |
31 | # count_missed_doses works as expected
32 |
33 | Code
34 | res
35 | Output
36 | A B
37 | ———————————————————————————————————————————————
38 | Missed Doses
39 | n 5 5
40 | At least 3 missed doses 3 (60%) 5 (83.3%)
41 | At least 7 missed doses 2 (40%) 2 (33.3%)
42 |
43 | # count_missed_doses works with denom argument specified
44 |
45 | Code
46 | res
47 | Output
48 | A B
49 | ————————————————————————————————————————————————
50 | x
51 | Missed Doses
52 | n 5 1
53 | At least 3 missed doses 3 (60%) 1 (100%)
54 | At least 7 missed doses 2 (40%) 1 (100%)
55 | y
56 | Missed Doses
57 | n 0 4
58 | At least 3 missed doses 0 4 (100%)
59 | At least 7 missed doses 0 1 (25%)
60 |
61 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/count_patients_events_in_cols.md:
--------------------------------------------------------------------------------
1 | # s_count_patients_and_multiple_events works as expected
2 |
3 | Code
4 | res
5 | Output
6 | $unique
7 | [1] 4
8 | attr(,"label")
9 | [1] "counts"
10 |
11 | $all
12 | [1] 7
13 | attr(,"label")
14 | [1] "counts"
15 |
16 | $serious
17 | count
18 | 7
19 | attr(,"label")
20 | [1] "counts"
21 |
22 | $fatal
23 | count
24 | 4
25 | attr(,"label")
26 | [1] "counts"
27 |
28 |
29 | # s_count_patients_and_multiple_events can have empty stats if requested
30 |
31 | Code
32 | res
33 | Output
34 | $unique
35 | [1] 4
36 | attr(,"label")
37 | [1] "counts"
38 |
39 | $all
40 | character(0)
41 | attr(,"label")
42 | [1] "counts"
43 |
44 | $serious
45 | character(0)
46 | attr(,"label")
47 | [1] "counts"
48 |
49 | $fatal
50 | count
51 | 4
52 | attr(,"label")
53 | [1] "counts"
54 |
55 |
56 | # summarize_patients_events_in_cols works well with default arguments
57 |
58 | Code
59 | res
60 | Output
61 | Patients (All) Events (All) Events (Related) fatal fatal_related
62 | —————————————————————————————————————————————————————————————————————————————————
63 | counts 4 7 5 4 4
64 |
65 | # summarize_patients_events_in_cols works well with custom arguments
66 |
67 | Code
68 | res
69 | Output
70 | Related All
71 | ———————————————————
72 | bla 5
73 |
74 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/coxph.md:
--------------------------------------------------------------------------------
1 | # univariate works correctly
2 |
3 | Code
4 | res
5 | Output
6 | [1] "SEX" "AGE" "RACE"
7 | attr(,"varname")
8 | [1] "c(\"SEX\", \"AGE\", \"RACE\")"
9 |
10 | ---
11 |
12 | Code
13 | res2
14 | Output
15 |
16 | Call:
17 | lm(formula = SEX ~ univariate(ARM), data = tern_ex_adsl)
18 |
19 | Coefficients:
20 | (Intercept) univariate(ARM)B: Placebo
21 | 1.4492754 0.0027794
22 | univariate(ARM)C: Combination
23 | -0.0009995
24 |
25 |
26 | # rht works correctly
27 |
28 | Code
29 | res
30 | Output
31 | [1] "+" "m * x" "b"
32 |
33 | # estimate_coef works correctly
34 |
35 | Code
36 | res
37 | Output
38 | coef se(coef) hr lcl ucl
39 | ARMCD/SEXM 0 0 1 1 1
40 |
41 | ---
42 |
43 | Code
44 | res
45 | Output
46 | [1] "Estimations of ARMCD hazard ratio given the level of SEX compared to ARMCD level ARM A."
47 |
48 | # try_car_anova works correctly
49 |
50 | Code
51 | res
52 | Output
53 | [1] 1.0000000 0.7521316 0.3858022
54 |
55 | ---
56 |
57 | Code
58 | res
59 | Output
60 | NULL
61 |
62 | # s_cox_multivariate works correctly with character input
63 |
64 | Code
65 | res
66 | Output
67 | Analysis of Deviance Table (Type III tests)
68 |
69 | Response: survival::Surv(time = AVAL, event = 1 - CNSR)
70 | Df Chisq Pr(>Chisq)
71 | ARMCD 2 1.1569 0.5608
72 | RACE 2 1.7917 0.4083
73 | AGE 1 0.0108 0.9174
74 | ARMCD:RACE 4 3.1853 0.5273
75 | ARMCD:AGE 2 1.1363 0.5666
76 | RACE:AGE 2 1.1686 0.5575
77 |
78 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/decorate_grob.md:
--------------------------------------------------------------------------------
1 | # split_string works with default settings
2 |
3 | Code
4 | res
5 | Output
6 | [1] "The species are Iris\nsetosa, versicolor,\nand virginica."
7 |
8 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/estimate_multinomial_rsp.md:
--------------------------------------------------------------------------------
1 | # d_onco_rsp_label provide right response labels
2 |
3 | Code
4 | res
5 | Output
6 | CR NE PR
7 | Complete Response (CR) Not Evaluable (NE) Partial Response (PR)
8 | Levels: Complete Response (CR) Partial Response (PR) Not Evaluable (NE)
9 |
10 | # d_onco_rsp_label describe label with x being a factor
11 |
12 | Code
13 | res
14 | Output
15 | CR SD PR
16 | Complete Response (CR) Stable Disease (SD) Partial Response (PR)
17 | PD NE
18 | Progressive Disease (PD) Not Evaluable (NE)
19 | 5 Levels: Complete Response (CR) Partial Response (PR) ... Not Evaluable (NE)
20 |
21 | # estimate_multinomial_response returns right result
22 |
23 | Code
24 | res
25 | Output
26 | A B C
27 | —————————————————————————————————————————————————————————————————————————————————————
28 | Complete Response (CR) 0 (0.0%) 2 (50.0%) 4 (100.0%)
29 | 95% CI (Wald, with correction) (0.00, 12.50) (0.00, 100.00) (87.50, 100.00)
30 | Partial Response (PR) 4 (100.0%) 2 (50.0%) 0 (0.0%)
31 | 95% CI (Wald, with correction) (87.50, 100.00) (0.00, 100.00) (0.00, 12.50)
32 |
33 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/fit_rsp_step.md:
--------------------------------------------------------------------------------
1 | # fit_rsp_step works as expected with default options
2 |
3 | Code
4 | res
5 | Output
6 | [1] 11
7 |
8 | ---
9 |
10 | Code
11 | res
12 | Output
13 | [1] "Percentile Center" "Percentile Lower" "Percentile Upper"
14 | [4] "Interval Center" "Interval Lower" "Interval Upper"
15 | [7] "n" "logor" "se"
16 | [10] "ci_lower" "ci_upper"
17 |
18 | # fit_rsp_step works as expected with global model fit
19 |
20 | Code
21 | res
22 | Output
23 | [1] 8
24 |
25 | ---
26 |
27 | Code
28 | res
29 | Output
30 | [1] "Interval Center" "Interval Lower" "Interval Upper" "n"
31 | [5] "logor" "se" "ci_lower" "ci_upper"
32 |
33 | # fit_rsp_step works as expected with strata
34 |
35 | Code
36 | res
37 | Output
38 | [1] 11
39 |
40 | ---
41 |
42 | Code
43 | res
44 | Output
45 | [1] "Percentile Center" "Percentile Lower" "Percentile Upper"
46 | [4] "Interval Center" "Interval Lower" "Interval Upper"
47 | [7] "n" "logor" "se"
48 | [10] "ci_lower" "ci_upper"
49 |
50 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/fit_survival_step.md:
--------------------------------------------------------------------------------
1 | # fit_survival_step works as expected with default options
2 |
3 | Code
4 | res
5 | Output
6 | [1] 12
7 |
8 | ---
9 |
10 | Code
11 | res
12 | Output
13 | [1] "Percentile Center" "Percentile Lower" "Percentile Upper"
14 | [4] "Interval Center" "Interval Lower" "Interval Upper"
15 | [7] "n" "events" "loghr"
16 | [10] "se" "ci_lower" "ci_upper"
17 |
18 | # fit_survival_step works as expected with global model fit
19 |
20 | Code
21 | res
22 | Output
23 | [1] 9
24 |
25 | ---
26 |
27 | Code
28 | res
29 | Output
30 | [1] "Interval Center" "Interval Lower" "Interval Upper" "n"
31 | [5] "events" "loghr" "se" "ci_lower"
32 | [9] "ci_upper"
33 |
34 | # fit_survival_step works as expected with null bandwidth
35 |
36 | Code
37 | res
38 | Output
39 | [1] 12
40 |
41 | ---
42 |
43 | Code
44 | res
45 | Output
46 | [1] "Percentile Center" "Percentile Lower" "Percentile Upper"
47 | [4] "Interval Center" "Interval Lower" "Interval Upper"
48 | [7] "n" "events" "loghr"
49 | [10] "se" "ci_lower" "ci_upper"
50 |
51 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/g_step.md:
--------------------------------------------------------------------------------
1 | # tidy.step works as expected for survival STEP results
2 |
3 | Code
4 | res
5 | Output
6 | [1] "Percentile Center" "Percentile Lower" "Percentile Upper"
7 | [4] "Interval Center" "Interval Lower" "Interval Upper"
8 | [7] "n" "events" "Hazard Ratio"
9 | [10] "se" "ci_lower" "ci_upper"
10 |
11 | ---
12 |
13 | Code
14 | res
15 | Output
16 | [1] "biomarker" "ci" "class" "estimate" "names" "row.names"
17 |
18 | # tidy.step works as expected for response STEP results
19 |
20 | Code
21 | res
22 | Output
23 | [1] "Percentile Center" "Percentile Lower" "Percentile Upper"
24 | [4] "Interval Center" "Interval Lower" "Interval Upper"
25 | [7] "n" "Odds Ratio" "se"
26 | [10] "ci_lower" "ci_upper"
27 |
28 | ---
29 |
30 | Code
31 | res
32 | Output
33 | [1] "biomarker" "ci" "class" "estimate" "names" "row.names"
34 |
35 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/h_biomarkers_subgroups.md:
--------------------------------------------------------------------------------
1 | # h_tab_rsp_one_biomarker works as expected
2 |
3 | Code
4 | res
5 | Output
6 | Total n Odds Ratio 95% CI
7 | ——————————————————————————————————————————————————
8 | All patients 48 0.99 (0.86, 1.15)
9 | All patients 48 1.00 (0.95, 1.06)
10 |
11 | # h_tab_surv_one_biomarker works as expected
12 |
13 | Code
14 | res
15 | Output
16 | Total n Hazard Ratio 95% Wald CI
17 | ————————————————————————————————————————————————————
18 | All patients 48 0.99 (0.86, 1.15)
19 | All patients 48 1.00 (0.95, 1.06)
20 |
21 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/h_format_row.md:
--------------------------------------------------------------------------------
1 | # h_format_row returns the correct dataframe
2 |
3 | Code
4 | res
5 | Output
6 | My Mean V1
7 | 1 50.0 (48.00, 51.00)
8 |
9 | ---
10 |
11 | Code
12 | res
13 | Output
14 | My Mean Mean 95% CI
15 | 1 50.0 (48.00, 51.00)
16 |
17 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/h_incidence_rate.md:
--------------------------------------------------------------------------------
1 | # h_incidence_rate_normal works as expected with healthy input
2 |
3 | Code
4 | res
5 | Output
6 | $rate
7 | [1] 0.01
8 |
9 | $rate_ci
10 | [1] -0.001630872 0.021630872
11 |
12 |
13 | # h_incidence_rate_normal_log works as expected with healthy input
14 |
15 | Code
16 | res
17 | Output
18 | $rate
19 | [1] 0.01
20 |
21 | $rate_ci
22 | [1] 0.003125199 0.031997963
23 |
24 |
25 | # h_incidence_rate_exact works as expected with healthy input
26 |
27 | Code
28 | res
29 | Output
30 | $rate
31 | [1] 0.01
32 |
33 | $rate_ci
34 | [1] 0.001776808 0.031478968
35 |
36 |
37 | # h_incidence_rate_byar works as expected with healthy input
38 |
39 | Code
40 | res
41 | Output
42 | $rate
43 | [1] 0.01
44 |
45 | $rate_ci
46 | [1] 0.002820411 0.027609866
47 |
48 |
49 | # h_incidence_rate works as expected with healthy input
50 |
51 | Code
52 | res
53 | Output
54 | $rate
55 | [1] 1
56 |
57 | $rate_ci
58 | [1] 0.3125199 3.1997963
59 |
60 |
61 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/h_pkparam_sort.md:
--------------------------------------------------------------------------------
1 | # h_pkparam_sort with PARAMCD
2 |
3 | Code
4 | res
5 | Output
6 | [1] "Cmax" "AUCinf obs" "CL obs" "Ae" "Fe"
7 | [6] "CLR" "Rmax" "Tonset" "RENALCLD"
8 |
9 | # h_pkparam_sort with out PARAMCD
10 |
11 | Code
12 | res
13 | Output
14 | [1] "Cmax" "AUCinf obs" "CL obs" "Ae" "Fe"
15 | [6] "CLR" "Rmax" "Tonset" "RENALCLD"
16 |
17 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/h_response_biomarkers_subgroups.md:
--------------------------------------------------------------------------------
1 | # h_rsp_to_logistic_variables works as expected
2 |
3 | Code
4 | res
5 | Output
6 | $response
7 | [1] "RSP"
8 |
9 | $arm
10 | [1] "AGE"
11 |
12 | $covariates
13 | [1] "A" "B"
14 |
15 | $strata
16 | [1] "D"
17 |
18 |
19 | # h_logistic_mult_cont_df works as expected
20 |
21 | Code
22 | res
23 | Output
24 | biomarker biomarker_label n_tot n_rsp prop or lcl
25 | 1 BMRKR1 Continuous Level Biomarker 1 200 164 0.82 0.9748324 0.8795800
26 | 2 AGE Age 200 164 0.82 0.9943862 0.9456819
27 | ucl conf_level pval pval_label
28 | 1 1.080400 0.95 0.6270504 p-value (Wald)
29 | 2 1.045599 0.95 0.8260959 p-value (Wald)
30 |
31 | # h_logistic_mult_cont_df returns missing values if data is empty (0 rows)
32 |
33 | Code
34 | res
35 | Output
36 | biomarker biomarker_label n_tot n_rsp prop or lcl ucl conf_level
37 | 1 BMRKR1 Continuous Level Biomarker 1 0 0 NA NA NA NA 0.95
38 | 2 AGE Age 0 0 NA NA NA NA 0.95
39 | pval pval_label
40 | 1 NA p-value (Wald)
41 | 2 NA p-value (Wald)
42 |
43 | # h_logistic_mult_cont_df also works with response not being called rsp
44 |
45 | Code
46 | res
47 | Output
48 | biomarker biomarker_label n_tot n_rsp prop or lcl
49 | 1 BMRKR1 Continuous Level Biomarker 1 200 164 0.82 0.9748324 0.8795800
50 | 2 AGE Age 200 164 0.82 0.9943862 0.9456819
51 | ucl conf_level pval pval_label
52 | 1 1.080400 0.95 0.6270504 p-value (Wald)
53 | 2 1.045599 0.95 0.8260959 p-value (Wald)
54 |
55 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/h_survival_biomarkers_subgroups.md:
--------------------------------------------------------------------------------
1 | # h_surv_to_coxreg_variables works as expected
2 |
3 | Code
4 | res
5 | Output
6 | $time
7 | [1] "AVAL"
8 |
9 | $event
10 | [1] "EVNT"
11 |
12 | $arm
13 | [1] "AGE"
14 |
15 | $covariates
16 | [1] "A" "B"
17 |
18 | $strata
19 | [1] "D"
20 |
21 |
22 | # h_coxreg_mult_cont_df works as expected
23 |
24 | Code
25 | res
26 | Output
27 | biomarker biomarker_label n_tot n_tot_events median hr
28 | 1 BMRKR1 Continuous Level Biomarker 1 200 141 753.5176 1.000735
29 | 2 AGE Age 200 141 753.5176 1.008458
30 | lcl ucl conf_level pval pval_label
31 | 1 0.9541338 1.049611 0.95 0.9759230 p-value (Wald)
32 | 2 0.9846171 1.032877 0.95 0.4901995 p-value (Wald)
33 |
34 | # h_coxreg_mult_cont_df returns missing values if data is empty (0 rows)
35 |
36 | Code
37 | res
38 | Output
39 | biomarker biomarker_label n_tot n_tot_events median hr lcl ucl
40 | 1 BMRKR1 Continuous Level Biomarker 1 0 0 NA NA NA NA
41 | 2 AGE Age 0 0 NA NA NA NA
42 | conf_level pval pval_label
43 | 1 0.95 NA p-value (Wald)
44 | 2 0.95 NA p-value (Wald)
45 |
46 |
--------------------------------------------------------------------------------
/tests/testthat/_snaps/imputation_rule.md:
--------------------------------------------------------------------------------
1 | # imputation_rule works correctly for 1/3 imputation rule
2 |
3 | Code
4 | result
5 | Output
6 | $val
7 | max
8 | 92.40745
9 |
10 | $na_str
11 | [1] "ND"
12 |
13 |
14 | ---
15 |
16 | Code
17 | result
18 | Output
19 | $val
20 | [1] NA
21 |
22 | $na_str
23 | [1] "ND"
24 |
25 |
26 | ---
27 |
28 | Code
29 | result
30 | Output
31 | $val
32 | geom_mean
33 | 40.22144
34 |
35 | $na_str
36 | [1] "NE"
37 |
38 |
39 | ---
40 |
41 | Code
42 | result
43 | Output
44 | $val
45 | max
46 | 99.26841
47 |
48 | $na_str
49 | [1] "ND"
50 |
51 |
52 | # imputation_rule works correctly for 1/2 imputation rule
53 |
54 | Code
55 | result
56 | Output
57 | $val
58 | max
59 | 92.40745
60 |
61 | $na_str
62 | [1] "NE"
63 |
64 |
65 | ---
66 |
67 | Code
68 | result
69 | Output
70 | $val
71 | mean
72 | 43.38858
73 |
74 | $na_str
75 | [1] "NE"
76 |
77 |
78 | ---
79 |
80 | Code
81 | result
82 | Output
83 | $val
84 | geom_mean
85 | 40.22144
86 |
87 | $na_str
88 | [1] "NE"
89 |
90 |
91 | ---
92 |
93 | Code
94 | result
95 | Output
96 | $val
97 | max
98 | 99.26841
99 |
100 | $na_str
101 | [1] "NE"
102 |
103 |
104 |
--------------------------------------------------------------------------------
/tests/testthat/setup-options.R:
--------------------------------------------------------------------------------
1 | # `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here)
2 | # it might happen that it is not used right now, but it is left for possible future use
3 | # use with: `withr::with_options(opts_partial_match_old, { ... })` inside the test
4 | opts_partial_match_old <- list(
5 | warnPartialMatchDollar = getOption("warnPartialMatchDollar"),
6 | warnPartialMatchArgs = getOption("warnPartialMatchArgs"),
7 | warnPartialMatchAttr = getOption("warnPartialMatchAttr")
8 | )
9 | opts_partial_match_new <- list(
10 | warnPartialMatchDollar = TRUE,
11 | warnPartialMatchArgs = TRUE,
12 | warnPartialMatchAttr = TRUE
13 | )
14 |
15 | if (isFALSE(getFromNamespace("on_cran", "testthat")()) && requireNamespace("withr", quietly = TRUE)) {
16 | withr::local_options(
17 | opts_partial_match_new,
18 | .local_envir = testthat::teardown_env()
19 | )
20 | }
21 |
--------------------------------------------------------------------------------
/tests/testthat/setup.R:
--------------------------------------------------------------------------------
1 | # Extra libraries (suggested) for tests
2 | library(dplyr)
3 |
4 | # skip_if_too_deep
5 | skip_if_too_deep <- function(depth) {
6 | checkmate::assert_number(depth, lower = 0, upper = 5)
7 |
8 | testing_depth <- getOption("TESTING_DEPTH")
9 | if (is.null(testing_depth)) testing_depth <- Sys.getenv("TESTING_DEPTH")
10 |
11 | testing_depth <- tryCatch(
12 | as.numeric(testing_depth),
13 | error = function(error) 3,
14 | warning = function(warning) 3
15 | )
16 |
17 | if (length(testing_depth) != 1 || is.na(testing_depth)) testing_depth <- 3
18 |
19 | if (testing_depth < depth) {
20 | testthat::skip(paste("testing depth", testing_depth, "is below current testing specification", depth))
21 | }
22 | }
23 |
24 | # expect_snapshot_ggplot - set custom plot dimensions
25 | expect_snapshot_ggplot <- function(title, fig, width = NA, height = NA, no_plot_snapshots = TRUE) {
26 | testthat::skip_on_ci()
27 | testthat::skip_if_not_installed("svglite")
28 | testthat::skip_if(no_plot_snapshots)
29 |
30 | name <- paste0(title, ".svg")
31 | path <- tempdir()
32 | withr::with_options(
33 | opts_partial_match_old,
34 | suppressMessages(ggplot2::ggsave(name, fig, path = path, width = width, height = height))
35 | )
36 | path <- file.path(path, name)
37 |
38 | testthat::announce_snapshot_file(name = name)
39 | testthat::expect_snapshot_file(path, name)
40 | }
41 |
--------------------------------------------------------------------------------
/tests/testthat/test-control_logistic.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("control_logistic works with customized parameters", {
2 | result <- control_logistic(
3 | conf_level = 0.9,
4 | response_definition = "response == 'bla'"
5 | )
6 |
7 | res <- testthat::expect_silent(result)
8 | testthat::expect_snapshot(res)
9 | })
10 |
11 | testthat::test_that("control_logistic fails wrong inputs", {
12 | testthat::expect_error(control_logistic(response_definition = "rsp"))
13 | testthat::expect_error(control_logistic(conf_level = 95))
14 | })
15 |
--------------------------------------------------------------------------------
/tests/testthat/test-control_step.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("control_step works with customized parameters", {
2 | result <- control_step(biomarker = 1:10, use_percentile = FALSE)
3 |
4 | res <- testthat::expect_silent(result)
5 | testthat::expect_snapshot(res)
6 | })
7 |
8 | testthat::test_that("control_step fails wrong inputs", {
9 | testthat::expect_error(control_step(biomarker = "5"))
10 | testthat::expect_error(control_step(bandwidth = 0))
11 | testthat::expect_error(control_step(num_points = 1))
12 | })
13 |
--------------------------------------------------------------------------------
/tests/testthat/test-control_survival.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("control_coxph works with customized parameters", {
2 | result <- control_coxph(
3 | pval_method = "wald", ties = "breslow", conf_level = 0.8
4 | )
5 |
6 | res <- testthat::expect_silent(result)
7 | testthat::expect_snapshot(res)
8 | })
9 |
10 | testthat::test_that("control_coxph fails wrong inputs", {
11 | testthat::expect_error(control_coxph(conf_level = 1.1))
12 | testthat::expect_error(control_coxph(pval_method = "bres"))
13 | })
14 |
15 | testthat::test_that("control_surv_time works with customized parameters", {
16 | result <- control_surv_time(
17 | conf_level = 0.8, conf_type = "log-log", quantiles = c(0.3, 0.8)
18 | )
19 |
20 | res <- testthat::expect_silent(result)
21 | testthat::expect_snapshot(res)
22 | })
23 |
24 | testthat::test_that("control_surv_time fails wrong inputs", {
25 | testthat::expect_error(control_surv_time(conf_level = 1.1))
26 | testthat::expect_error(control_surv_time(quantiles = 0.8))
27 | testthat::expect_error(control_surv_time(conf_type = "none"))
28 | })
29 |
30 | testthat::test_that("control_surv_timepoint works with customized parameters", {
31 | result <- control_surv_timepoint(
32 | conf_level = 0.8, conf_type = "log-log"
33 | )
34 |
35 | res <- testthat::expect_silent(result)
36 | testthat::expect_snapshot(res)
37 | })
38 |
39 | testthat::test_that("control_surv_timepoint fails wrong inputs", {
40 | testthat::expect_error(control_surv_timepoint(conf_level = 1.5))
41 | testthat::expect_error(control_surv_timepoint(time_point = c(4, 6)))
42 | testthat::expect_error(control_surv_timepoint(conf_type = "none"))
43 | })
44 |
--------------------------------------------------------------------------------
/tests/testthat/test-count_missed_doses.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("d_count_missed_doses works as expected", {
2 | result <- d_count_missed_doses(c(1, 5))
3 |
4 | res <- testthat::expect_silent(result)
5 | testthat::expect_snapshot(res)
6 | })
7 |
8 | testthat::test_that("s_count_missed_doses works as expected", {
9 | result <- s_count_missed_doses(
10 | x = c(0, 1, 0, 2, 3, 4, 0, 2),
11 | thresholds = c(2, 5),
12 | .N_col = 10,
13 | .N_row = 10
14 | )
15 |
16 | res <- testthat::expect_silent(result)
17 | testthat::expect_snapshot(res)
18 | })
19 |
20 | testthat::test_that("count_missed_doses works as expected", {
21 | set.seed(1)
22 | df <- data.frame(
23 | a = c(sample(1:10, 10), NA),
24 | grp = factor(c(rep("A", 5), rep("B", 6)), levels = c("A", "B"))
25 | )
26 |
27 | result <- basic_table() %>%
28 | split_cols_by("grp") %>%
29 | count_missed_doses(
30 | "a",
31 | thresholds = c(3, 7),
32 | var_labels = "Missed Doses"
33 | ) %>%
34 | build_table(df)
35 |
36 | res <- testthat::expect_silent(result)
37 | testthat::expect_snapshot(res)
38 | })
39 |
40 | testthat::test_that("count_missed_doses works with denom argument specified", {
41 | set.seed(1)
42 | df <- data.frame(
43 | a = c(sample(1:10, 10), NA),
44 | type = factor(sample(c("x", "y"), 11, replace = TRUE)),
45 | grp = factor(c(rep("A", 5), rep("B", 6)), levels = c("A", "B"))
46 | )
47 |
48 | result <- basic_table() %>%
49 | split_cols_by("grp") %>%
50 | split_rows_by("type") %>%
51 | count_missed_doses(
52 | "a",
53 | thresholds = c(3, 7),
54 | var_labels = "Missed Doses",
55 | denom = "n"
56 | ) %>%
57 | build_table(df)
58 |
59 | res <- testthat::expect_silent(result)
60 | testthat::expect_snapshot(res)
61 | })
62 |
--------------------------------------------------------------------------------
/tests/testthat/test-estimate_multinomial_rsp.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("d_onco_rsp_label provide right response labels", {
2 | rsp <- c("CR", "NE", "PR")
3 | result <- d_onco_rsp_label(rsp)
4 |
5 | res <- testthat::expect_silent(result)
6 | testthat::expect_snapshot(res)
7 | })
8 |
9 | testthat::test_that("d_onco_rsp_label describe label with x being a factor", {
10 | a <- factor(c("CR", "SD", "PR", "PD", "NE"))
11 | result <- d_onco_rsp_label(a)
12 |
13 | res <- testthat::expect_silent(result)
14 | testthat::expect_snapshot(res)
15 | })
16 |
17 | testthat::test_that("s_length_proportion works as expected with healthy input", {
18 | x <- rep("A", 10)
19 | n_col <- 20
20 | result <- s_length_proportion(x = x, .N_col = n_col, method = "jeffreys", conf_level = 0.8)
21 | expected <- s_proportion(df = rep(c(TRUE, FALSE), c(10, 10)), method = "jeffreys", conf_level = 0.8)
22 | testthat::expect_identical(result, expected)
23 | })
24 |
25 | testthat::test_that("s_length_proportion fails with bad input", {
26 | testthat::expect_error(s_length_proportion(x = c(1, 1, 1), 10))
27 | testthat::expect_error(s_length_proportion(x = c("A", "B"), 10))
28 | testthat::expect_error(s_length_proportion(x = rep("A", 20), 10))
29 | })
30 |
31 | testthat::test_that("estimate_multinomial_response returns right result", {
32 | # Preparation of a common test case for unit tests.
33 | dta_test <- data.frame(
34 | USUBJID = paste0("S", 1:12),
35 | ARM = rep(LETTERS[1:3], each = 4),
36 | AVAL = c(A = c(1, 1, 1, 1), B = c(0, 0, 1, 1), C = c(0, 0, 0, 0))
37 | )
38 | dta_test$AVALC <- as.factor(c(
39 | "Complete Response (CR)", "Partial Response (PR)"
40 | )[dta_test$AVAL + 1])
41 |
42 | lyt <- basic_table() %>%
43 | split_cols_by(var = "ARM") %>%
44 | estimate_multinomial_response(var = "AVALC")
45 | result <- build_table(lyt = lyt, df = dta_test)
46 |
47 | res <- testthat::expect_silent(result)
48 | testthat::expect_snapshot(res)
49 | })
50 |
--------------------------------------------------------------------------------
/tests/testthat/test-g_waterfall.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("g_waterfall default plot works", {
2 | testthat::expect_silent(g_waterfall <- g_waterfall(
3 | height = c(3, 5, -1),
4 | id = letters[1:3],
5 | col = NULL
6 | ))
7 | expect_snapshot_ggplot(title = "g_waterfall", fig = g_waterfall, width = 10, height = 8)
8 | })
9 |
10 | testthat::test_that("g_waterfall plot with labels and colors works", {
11 | set.seed(123)
12 |
13 | adrs <- tern_ex_adrs
14 | adrs_f <- head(dplyr::filter(adrs, PARAMCD == "OVRINV"), 30)
15 | adrs_f$pchg <- rnorm(30, 10, 50)
16 | adrs_f <- adrs_f[!duplicated(adrs_f$USUBJID), ]
17 |
18 | testthat::expect_silent(g_waterfall_decorated <-
19 | g_waterfall(
20 | height = adrs_f$pchg,
21 | id = paste("asdfdsfdsfsd", adrs_f$USUBJID),
22 | col_var = adrs_f$SEX,
23 | col = "blue",
24 | xlab = "ID",
25 | ylab = "Percentage Change",
26 | title = "Waterfall plot"
27 | ))
28 |
29 | expect_snapshot_ggplot(title = "g_waterfall_decorated", fig = g_waterfall_decorated, width = 10, height = 8)
30 | })
31 |
--------------------------------------------------------------------------------
/tests/testthat/test-h_biomarkers_subgroups.R:
--------------------------------------------------------------------------------
1 | ## Deprecated ------------------------------------------------------------
2 |
3 | testthat::test_that("h_tab_rsp_one_biomarker works as expected", {
4 | df <- data.frame(
5 | n_tot = c(48L, 48L),
6 | n_rsp = c(24L, 24L),
7 | prop = c(0.5, 0.5),
8 | or = c(0.992727618706316, 1.00485769099575),
9 | lcl = c(0.859391304891713, 0.950491104268725),
10 | ucl = c(1.14675133356916, 1.06233396043214),
11 | conf_level = c(0.95, 0.95),
12 | pval = c(0.920991170690111, 0.864415775291559),
13 | pval_label = c("p-value (Wald)", "p-value (Wald)"),
14 | subgroup = c("All patients", "All patients"),
15 | row_type = c("content", "content"),
16 | var = c("ALL", "ALL"),
17 | var_label = c("All patients", "All patients")
18 | )
19 | lifecycle::expect_deprecated(lifecycle::expect_deprecated(
20 | res <- h_tab_rsp_one_biomarker(
21 | df = df,
22 | vars = c("n_tot", "or", "ci")
23 | )
24 | ))
25 |
26 | testthat::expect_snapshot(res)
27 | })
28 |
29 | testthat::test_that("h_tab_surv_one_biomarker works as expected", {
30 | df <- data.frame(
31 | n_tot = c(48L, 48L),
32 | n_tot_events = c(25L, 25L),
33 | median = c(1269.40388857211, 1269.40388857211),
34 | hr = c(0.992727618706316, 1.00485769099575),
35 | lcl = c(0.859391304891713, 0.950491104268725),
36 | ucl = c(1.14675133356916, 1.06233396043214),
37 | conf_level = c(0.95, 0.95),
38 | pval = c(0.920991170690111, 0.864415775291559),
39 | pval_label = c("p-value (Wald)", "p-value (Wald)"),
40 | subgroup = c("All patients", "All patients"),
41 | row_type = c("content", "content"),
42 | var = c("ALL", "ALL"),
43 | var_label = c("All patients", "All patients")
44 | )
45 | lifecycle::expect_deprecated(lifecycle::expect_deprecated(
46 | result <- h_tab_surv_one_biomarker(
47 | df = df,
48 | vars = c("n_tot", "hr", "ci"),
49 | time_unit = "months"
50 | )
51 | ))
52 |
53 | res <- testthat::expect_silent(result)
54 | testthat::expect_snapshot(res)
55 | })
56 |
--------------------------------------------------------------------------------
/tests/testthat/test-h_format_row.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("h_format_row returns the correct dataframe", {
2 | format <- c(mean = "xx.x", mean_ci = "(xx.xx, xx.xx)")
3 | labels <- c(mean = "My Mean")
4 |
5 | # test 1
6 | mean_ci <- c(48, 51)
7 | x <- list(mean = 50, mean_ci = mean_ci)
8 | result <- h_format_row(x, format, labels)
9 |
10 | res <- testthat::expect_silent(result)
11 | testthat::expect_snapshot(res)
12 |
13 | # test 2
14 | attr(mean_ci, "label") <- "Mean 95% CI"
15 | x <- list(mean = 50, mean_ci = mean_ci)
16 | result <- h_format_row(x, format, labels)
17 |
18 | res <- testthat::expect_silent(result)
19 | testthat::expect_snapshot(res)
20 | })
21 |
--------------------------------------------------------------------------------
/tests/testthat/test-h_incidence_rate.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("h_incidence_rate_normal works as expected with healthy input", {
2 | result <- h_incidence_rate_normal(200, 2, 0.1)
3 |
4 | res <- testthat::expect_silent(result)
5 | testthat::expect_snapshot(res)
6 | })
7 |
8 | testthat::test_that("h_incidence_rate_normal_log works as expected with healthy input", {
9 | result <- h_incidence_rate_normal_log(200, 2, 0.1)
10 |
11 | res <- testthat::expect_silent(result)
12 | testthat::expect_snapshot(res)
13 | })
14 |
15 | testthat::test_that("h_incidence_rate_exact works as expected with healthy input", {
16 | result <- h_incidence_rate_exact(200, 2, 0.1)
17 |
18 | res <- testthat::expect_silent(result)
19 | testthat::expect_snapshot(res)
20 | })
21 |
22 | testthat::test_that("h_incidence_rate_byar works as expected with healthy input", {
23 | result <- h_incidence_rate_byar(200, 2, 0.1)
24 |
25 | res <- testthat::expect_silent(result)
26 | testthat::expect_snapshot(res)
27 | })
28 |
29 | testthat::test_that("h_incidence_rate works as expected with healthy input", {
30 | result <- h_incidence_rate(
31 | 200,
32 | 2,
33 | control_incidence_rate(conf_level = 0.9, conf_type = "normal_log", num_pt_year = 100)
34 | )
35 |
36 | res <- testthat::expect_silent(result)
37 | testthat::expect_snapshot(res)
38 | })
39 |
--------------------------------------------------------------------------------
/tests/testthat/test-h_pkparam_sort.R:
--------------------------------------------------------------------------------
1 | testthat::test_that("h_pkparam_sort with PARAMCD", {
2 | sorted_adpp <- tern_ex_adpp %>% h_pkparam_sort()
3 | result_tlg_display <- levels(sorted_adpp$TLG_DISPLAY)
4 |
5 | res <- testthat::expect_silent(result_tlg_display)
6 | testthat::expect_snapshot(res)
7 | })
8 |
9 | testthat::test_that("h_pkparam_sort with out PARAMCD", {
10 | adpp_1 <- tern_ex_adpp
11 | adpp_1[["pktest"]] <- tern_ex_adpp$PARAMCD
12 | adpp_1$PARAMCD <- NULL
13 | sorted_adpp <- adpp_1 %>% h_pkparam_sort("pktest")
14 | result_tlg_display <- levels(sorted_adpp$TLG_DISPLAY)
15 |
16 | res <- testthat::expect_silent(result_tlg_display)
17 | testthat::expect_snapshot(res)
18 | })
19 |
--------------------------------------------------------------------------------
/tests/testthat/test-imputation_rule.R:
--------------------------------------------------------------------------------
1 | set.seed(1)
2 | df <- data.frame(
3 | ARM = with_label(rep("A: Drug X", 162), "Arm"),
4 | AVAL = runif(162, 0, 100),
5 | AVALCAT1 = as.factor(sample(c(1, "BLQ"), 162, replace = TRUE)),
6 | VISIT = with_label(as.factor(rep(c(rep("Day 1", 5), rep("Day 2", 4)), 18)), "Visit"),
7 | NFRLT = with_label(as.factor(rep(c(0, seq(0, 42, 6)), 18)), "Nominal Time")
8 | )
9 |
10 | testthat::test_that("imputation_rule works correctly for 1/3 imputation rule", {
11 | x_stats <- s_summary(df$AVAL[df$NFRLT == 0])
12 | result <- imputation_rule(df, x_stats, "max", "1/3")
13 | res <- testthat::expect_snapshot(result)
14 |
15 | x_stats <- s_summary(df$AVAL[df$NFRLT == 0])
16 | result <- imputation_rule(df, x_stats, "mean", "1/3")
17 | res <- testthat::expect_snapshot(result)
18 |
19 | x_stats <- s_summary(df$AVAL[df$NFRLT == 6])
20 | result <- imputation_rule(df, x_stats, "geom_mean", "1/3", post = TRUE)
21 | res <- testthat::expect_snapshot(result)
22 |
23 | x_stats <- s_summary(df$AVAL[df$NFRLT == 18])
24 | result <- imputation_rule(df, x_stats, "max", "1/3", post = TRUE)
25 | res <- testthat::expect_snapshot(result)
26 | })
27 |
28 | testthat::test_that("imputation_rule works correctly for 1/2 imputation rule", {
29 | x_stats <- s_summary(df$AVAL[df$NFRLT == 0])
30 | result <- imputation_rule(df, x_stats, "max", "1/2")
31 | res <- testthat::expect_snapshot(result)
32 |
33 | x_stats <- s_summary(df$AVAL[df$NFRLT == 0])
34 | result <- imputation_rule(df, x_stats, "mean", "1/2")
35 | res <- testthat::expect_snapshot(result)
36 |
37 | x_stats <- s_summary(df$AVAL[df$NFRLT == 6])
38 | result <- imputation_rule(df, x_stats, "geom_mean", "1/2", post = TRUE)
39 | res <- testthat::expect_snapshot(result)
40 |
41 | x_stats <- s_summary(df$AVAL[df$NFRLT == 18])
42 | result <- imputation_rule(df, x_stats, "max", "1/2", post = TRUE)
43 | res <- testthat::expect_snapshot(result)
44 | })
45 |
--------------------------------------------------------------------------------
/tests/testthat/test-summarize_colvars.R:
--------------------------------------------------------------------------------
1 | dta_local <- data.frame(
2 | ARM = rep(c("A", "B"), 9),
3 | USUBJID = rep(1:6, each = 3),
4 | AVISIT = rep(paste0("V", 1:3), 6),
5 | AVAL = c(9:1, rep(NA, 9))
6 | ) %>%
7 | dplyr::mutate(
8 | ABLFLL = AVISIT == "V1"
9 | ) %>%
10 | dplyr::group_by(USUBJID) %>%
11 | dplyr::mutate(
12 | BLVAL = AVAL[ABLFLL],
13 | CHG = AVAL - BLVAL
14 | ) %>%
15 | dplyr::ungroup()
16 |
17 | testthat::test_that("summarize_colvars works as expected without column split and default behavior", {
18 | dta <- dta_local
19 |
20 | l <- basic_table() %>%
21 | split_rows_by("AVISIT") %>%
22 | split_cols_by_multivar(vars = c("AVAL", "CHG")) %>%
23 | summarize_colvars()
24 |
25 | result <- build_table(l, dta)
26 |
27 | res <- testthat::expect_silent(result)
28 | testthat::expect_snapshot(res)
29 | })
30 |
31 | testthat::test_that("summarize_colvars works as expected with column split", {
32 | dta <- dta_local
33 |
34 | l <- basic_table() %>%
35 | split_cols_by("ARM") %>%
36 | split_rows_by("AVISIT") %>%
37 | split_cols_by_multivar(vars = c("AVAL", "CHG")) %>%
38 | summarize_colvars()
39 |
40 | result <- build_table(l, dta)
41 |
42 | res <- testthat::expect_silent(result)
43 | testthat::expect_snapshot(res)
44 | })
45 |
46 | testthat::test_that("summarize_colvars works when selecting statistics and custom formatting", {
47 | dta <- dta_local
48 |
49 | l <- basic_table() %>%
50 | split_cols_by("ARM") %>%
51 | split_rows_by("AVISIT") %>%
52 | split_cols_by_multivar(vars = c("AVAL", "CHG")) %>%
53 | summarize_colvars(
54 | .stats = c("n", "mean_sd"),
55 | .formats = c("mean_sd" = "xx.x, xx.x"),
56 | .labels = c(n = "n", mean_sd = "Mean, SD"),
57 | .indent_mods = c(n = 2L, mean_sd = 5L)
58 | )
59 |
60 | result <- build_table(l, dta)
61 |
62 | res <- testthat::expect_silent(result)
63 | testthat::expect_snapshot(res)
64 | })
65 |
--------------------------------------------------------------------------------