├── .Rbuildignore ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug.yml │ ├── config.yml │ ├── cran-release.yml │ ├── feature.yml │ ├── question.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 ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS.md ├── R ├── argument_convention.R ├── arm_ref_comp.R ├── data.R ├── facet_grid_formula.R ├── labels.R ├── string_ops.R ├── substitute_names.R ├── teal.modules.clinical.R ├── tm_a_gee.R ├── tm_a_mmrm.R ├── tm_g_barchart_simple.R ├── tm_g_ci.R ├── tm_g_forest_rsp.R ├── tm_g_forest_tte.R ├── tm_g_ipp.R ├── tm_g_km.R ├── tm_g_lineplot.R ├── tm_g_pp_adverse_events.R ├── tm_g_pp_patient_timeline.R ├── tm_g_pp_therapy.R ├── tm_g_pp_vitals.R ├── tm_t_abnormality.R ├── tm_t_abnormality_by_worst_grade.R ├── tm_t_ancova.R ├── tm_t_binary_outcome.R ├── tm_t_coxreg.R ├── tm_t_events.R ├── tm_t_events_by_grade.R ├── tm_t_events_patyear.R ├── tm_t_events_summary.R ├── tm_t_exposure.R ├── tm_t_logistic.R ├── tm_t_mult_events.R ├── tm_t_pp_basic_info.R ├── tm_t_pp_laboratory.R ├── tm_t_pp_medical_history.R ├── tm_t_pp_prior_medication.R ├── tm_t_shift_by_arm.R ├── tm_t_shift_by_arm_by_worst.R ├── tm_t_shift_by_grade.R ├── tm_t_smq.R ├── tm_t_summary.R ├── tm_t_summary_by.R ├── tm_t_tte.R ├── utils.R ├── validate_standard_inputs.R └── zzz.R ├── README.md ├── SECURITY.md ├── _pkgdown.yml ├── data ├── tmc_ex_adae.rda ├── tmc_ex_adaette.rda ├── tmc_ex_adcm.rda ├── tmc_ex_adeg.rda ├── tmc_ex_adex.rda ├── tmc_ex_adlb.rda ├── tmc_ex_admh.rda ├── tmc_ex_adqs.rda ├── tmc_ex_adrs.rda ├── tmc_ex_adsl.rda ├── tmc_ex_adtte.rda └── tmc_ex_advs.rda ├── inst ├── WORDLIST └── css │ └── custom.css ├── man-roxygen ├── author_liaoc10.R ├── author_song24.R ├── author_waddella.R ├── author_wangh107.R └── param_plot_height.R ├── man ├── add_expr.Rd ├── arm_ref_comp_observer.Rd ├── as_num.Rd ├── bracket_expr.Rd ├── call_concatenate.Rd ├── check_arm_ref_comp.Rd ├── clean_description.Rd ├── color_lab_values.Rd ├── column_annotation_label.Rd ├── control_tte.Rd ├── cs_to_des_filter.Rd ├── cs_to_des_select.Rd ├── cs_to_filter_spec.Rd ├── cs_to_select_spec.Rd ├── default_total_label.Rd ├── ex_data.Rd ├── extract_input.Rd ├── facet_grid_formula.Rd ├── get_g_forest_obj_var_name.Rd ├── get_paramcd_label.Rd ├── get_var_labels.Rd ├── h_concat_expr.Rd ├── is.cs_or_des.Rd ├── make_barchart_simple_call.Rd ├── module_arguments.Rd ├── pipe_expr.Rd ├── prepare_arm.Rd ├── prepare_arm_levels.Rd ├── select_decorators.Rd ├── split_choices.Rd ├── split_col_expr.Rd ├── split_interactions.Rd ├── srv_decorate_teal_data.Rd ├── substitute_names.Rd ├── substitute_q.Rd ├── teal.modules.clinical-package.Rd ├── template_a_gee.Rd ├── template_abnormality.Rd ├── template_abnormality_by_worst_grade.Rd ├── template_adverse_events.Rd ├── template_ancova.Rd ├── template_arguments.Rd ├── template_basic_info.Rd ├── template_binary_outcome.Rd ├── template_coxreg_m.Rd ├── template_coxreg_u.Rd ├── template_events.Rd ├── template_events_by_grade.Rd ├── template_events_col_by_grade.Rd ├── template_events_patyear.Rd ├── template_events_summary.Rd ├── template_exposure.Rd ├── template_fit_mmrm.Rd ├── template_forest_rsp.Rd ├── template_forest_tte.Rd ├── template_g_ci.Rd ├── template_g_ipp.Rd ├── template_g_km.Rd ├── template_g_lineplot.Rd ├── template_laboratory.Rd ├── template_logistic.Rd ├── template_medical_history.Rd ├── template_mult_events.Rd ├── template_patient_timeline.Rd ├── template_prior_medication.Rd ├── template_shift_by_arm.Rd ├── template_shift_by_arm_by_worst.Rd ├── template_shift_by_grade.Rd ├── template_smq.Rd ├── template_summary.Rd ├── template_summary_by.Rd ├── template_therapy.Rd ├── template_tte.Rd ├── template_vitals.Rd ├── tm_a_gee.Rd ├── tm_a_mmrm.Rd ├── tm_g_barchart_simple.Rd ├── tm_g_ci.Rd ├── tm_g_forest_rsp.Rd ├── tm_g_forest_tte.Rd ├── tm_g_ipp.Rd ├── tm_g_km.Rd ├── tm_g_lineplot.Rd ├── tm_g_pp_adverse_events.Rd ├── tm_g_pp_patient_timeline.Rd ├── tm_g_pp_therapy.Rd ├── tm_g_pp_vitals.Rd ├── tm_t_abnormality.Rd ├── tm_t_abnormality_by_worst_grade.Rd ├── tm_t_ancova.Rd ├── tm_t_binary_outcome.Rd ├── tm_t_coxreg.Rd ├── tm_t_events.Rd ├── tm_t_events_by_grade.Rd ├── tm_t_events_patyear.Rd ├── tm_t_events_summary.Rd ├── tm_t_exposure.Rd ├── tm_t_logistic.Rd ├── tm_t_mult_events.Rd ├── tm_t_pp_basic_info.Rd ├── tm_t_pp_laboratory.Rd ├── tm_t_pp_medical_history.Rd ├── tm_t_pp_prior_medication.Rd ├── tm_t_shift_by_arm.Rd ├── tm_t_shift_by_arm_by_worst.Rd ├── tm_t_shift_by_grade.Rd ├── tm_t_smq.Rd ├── tm_t_summary.Rd ├── tm_t_summary_by.Rd ├── tm_t_tte.Rd ├── validate_arm.Rd └── validate_standard_inputs.Rd ├── revdep └── .gitignore ├── staged_dependencies.yaml ├── teal.modules.clinical.Rproj ├── tests ├── testthat.R └── testthat │ ├── _snaps │ ├── tm_a_gee.md │ ├── tm_a_mmrm.md │ ├── tm_g_ci.md │ ├── tm_g_forest_rsp.md │ ├── tm_g_forest_tte.md │ ├── tm_g_ipp.md │ ├── tm_g_km.md │ ├── tm_g_lineplot.md │ ├── tm_t_abnormality.md │ ├── tm_t_abnormality_by_worst_grade.md │ ├── tm_t_ancova.md │ ├── tm_t_binary_outcome.md │ ├── tm_t_coxreg.md │ ├── tm_t_events.md │ ├── tm_t_events_by_grade.md │ ├── tm_t_events_patyear.md │ ├── tm_t_events_summary.md │ ├── tm_t_exposure.md │ ├── tm_t_logisitic.md │ ├── tm_t_mult_events.md │ ├── tm_t_pp_medical_history.md │ ├── tm_t_shift_by_arm.md │ ├── tm_t_shift_by_arm_by_worst.md │ ├── tm_t_shift_by_grade.md │ ├── tm_t_smq.md │ ├── tm_t_summary.md │ ├── tm_t_summary_by.md │ ├── tm_t_tte.md │ └── utils.md │ ├── helper-TealAppDriver.R │ ├── helper-testing-depth.R │ ├── setup-logger.R │ ├── setup-options.R │ ├── test-examples.R │ ├── test-facet_grid_formula.R │ ├── test-shinytest2-tm_a_gee.R │ ├── test-shinytest2-tm_a_mmrm.R │ ├── test-shinytest2-tm_g_barchart_simple.R │ ├── test-shinytest2-tm_g_ci.R │ ├── test-shinytest2-tm_g_forest_rsp.R │ ├── test-shinytest2-tm_g_forest_tte.R │ ├── test-shinytest2-tm_g_ipp.R │ ├── test-shinytest2-tm_g_km.R │ ├── test-shinytest2-tm_g_lineplot.R │ ├── test-shinytest2-tm_g_pp_adverse_events.R │ ├── test-shinytest2-tm_g_pp_patient_timeline.R │ ├── test-shinytest2-tm_g_pp_therapy.R │ ├── test-shinytest2-tm_g_pp_vitals.R │ ├── test-shinytest2-tm_t_abnormality.R │ ├── test-shinytest2-tm_t_abnormality_by_worst_grade.R │ ├── test-shinytest2-tm_t_ancova.R │ ├── test-shinytest2-tm_t_binary_outcome.R │ ├── test-shinytest2-tm_t_coxreg.R │ ├── test-shinytest2-tm_t_events.R │ ├── test-shinytest2-tm_t_events_by_grade.R │ ├── test-shinytest2-tm_t_events_patyear.R │ ├── test-shinytest2-tm_t_events_summary.R │ ├── test-shinytest2-tm_t_exposure.R │ ├── test-shinytest2-tm_t_logistic.R │ ├── test-shinytest2-tm_t_mult_events.R │ ├── test-shinytest2-tm_t_pp_basic_info.R │ ├── test-shinytest2-tm_t_pp_laboratory.R │ ├── test-shinytest2-tm_t_pp_medical_history.R │ ├── test-shinytest2-tm_t_pp_prior_medication.R │ ├── test-shinytest2-tm_t_shift_by_arm.R │ ├── test-shinytest2-tm_t_shift_by_arm_by_worst.R │ ├── test-shinytest2-tm_t_shift_by_grade.R │ ├── test-shinytest2-tm_t_smq.R │ ├── test-shinytest2-tm_t_summary.R │ ├── test-shinytest2-tm_t_summary_by.R │ ├── test-shinytest2-tm_t_tte.R │ ├── test-string_ops.R │ ├── test-substitute_names.R │ ├── test-tm_a_gee.R │ ├── test-tm_a_mmrm.R │ ├── test-tm_g_ci.R │ ├── test-tm_g_forest_rsp.R │ ├── test-tm_g_forest_tte.R │ ├── test-tm_g_ipp.R │ ├── test-tm_g_km.R │ ├── test-tm_g_lineplot.R │ ├── test-tm_t_abnormality.R │ ├── test-tm_t_abnormality_by_worst_grade.R │ ├── test-tm_t_ancova.R │ ├── test-tm_t_binary_outcome.R │ ├── test-tm_t_coxreg.R │ ├── test-tm_t_events.R │ ├── test-tm_t_events_by_grade.R │ ├── test-tm_t_events_patyear.R │ ├── test-tm_t_events_summary.R │ ├── test-tm_t_exposure.R │ ├── test-tm_t_logisitic.R │ ├── test-tm_t_mult_events.R │ ├── test-tm_t_pp_medical_history.R │ ├── test-tm_t_shift_by_arm.R │ ├── test-tm_t_shift_by_arm_by_worst.R │ ├── test-tm_t_shift_by_grade.R │ ├── test-tm_t_smq.R │ ├── test-tm_t_summary.R │ ├── test-tm_t_summary_by.R │ ├── test-tm_t_tte.R │ ├── test-utils.R │ └── test-validate_standard_inputs.R └── vignettes ├── decorate-module-output.Rmd ├── generate_tmc_test_data.Rmd ├── quickstart_substitute.Rmd └── teal-modules-clinical.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^renv$ 2 | ^renv\.lock$ 3 | CODE_OF_CONDUCT.md 4 | SECURITY.md 5 | ^_dev$ 6 | ^.*\.Rproj$ 7 | ^[^/]+\.html$ 8 | ^[^/]+\.png$ 9 | ^[^/]+\.R$ 10 | ^[^/]+\.Rmd$ 11 | ^\_pkgdown\.yaml$ 12 | ^\_pkgdown\.yml 13 | ^\.CI-FORCE-RELEASE-VERSION$ 14 | ^\.drone\.yml$ 15 | ^\.github$ 16 | ^\.git$ 17 | ^\.lintr$ 18 | ^\.Rprofile$ 19 | ^\.Rproj\.user$ 20 | ^\.travis\.yml$ 21 | ^build_docker_image$ 22 | ^cache$ 23 | ^data-raw$ 24 | ^data/script\.R$ 25 | ^design$ 26 | ^dev$ 27 | ^doc$ 28 | ^docs$ 29 | ^Jenkinsfile$ 30 | ^logs$ 31 | ^Makefile$ 32 | ^man-roxygen$ 33 | ^Meta$ 34 | ^outputdir$ 35 | ^scratch$ 36 | ^stubs$ 37 | ^temp$ 38 | ^templates$ 39 | ^test_full_example$ 40 | ^TODO\.md$ 41 | ^staged_dependencies\.yaml$ 42 | ^\.gitlab-ci\.yml$ 43 | ^\.pre-commit-config\.yaml$ 44 | ^LICENSE\.md$ 45 | LICENSE 46 | coverage.* 47 | ^pkgdown$ 48 | ^.revdeprefs\.yaml$ 49 | ^revdep$ 50 | ^\.covrignore$ 51 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐞 Bug Report 3 | description: File a bug report 4 | title: "[Bug]: " 5 | labels: ["bug"] 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Thanks for taking the time to fill out this bug report! 11 | - type: textarea 12 | id: what-happened 13 | attributes: 14 | label: What happened? 15 | description: Also tell us, what did you expect to happen? 16 | placeholder: Tell us what you see! 17 | value: "A bug happened!" 18 | validations: 19 | required: true 20 | - type: textarea 21 | id: session-info 22 | attributes: 23 | label: sessionInfo() 24 | description: Please copy and paste your output from `sessionInfo()`. This will be automatically formatted into code, so no need for backticks. 25 | render: R 26 | - type: textarea 27 | id: logs 28 | attributes: 29 | label: Relevant log output 30 | description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. 31 | render: R 32 | - type: checkboxes 33 | id: code-of-conduct 34 | attributes: 35 | label: Code of Conduct 36 | description: By submitting this issue, you agree to follow our [Code of Conduct.](https://insightsengineering.github.io/teal.modules.clinical/CODE_OF_CONDUCT.html) 37 | options: 38 | - label: I agree to follow this project's Code of Conduct. 39 | required: true 40 | - type: checkboxes 41 | id: contributor-guidelines 42 | attributes: 43 | label: Contribution Guidelines 44 | description: By submitting this issue, you agree to follow our [Contribution Guidelines.](https://insightsengineering.github.io/teal.modules.clinical/CONTRIBUTING.html) 45 | options: 46 | - label: I agree to follow this project's Contribution Guidelines. 47 | required: true 48 | - type: checkboxes 49 | id: security-policy 50 | attributes: 51 | label: Security Policy 52 | description: By submitting this issue, you agree to follow our [Security Policy.](https://github.com/insightsengineering/teal.modules.clinical/security/policy) 53 | options: 54 | - label: I agree to follow this project's Security Policy. 55 | required: true 56 | -------------------------------------------------------------------------------- /.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]: <title>" 5 | labels: ["enhancement"] 6 | body: 7 | - type: textarea 8 | attributes: 9 | label: Feature description 10 | validations: 11 | required: true 12 | - type: checkboxes 13 | id: code-of-conduct 14 | attributes: 15 | label: Code of Conduct 16 | description: By submitting this issue, you agree to follow our [Code of Conduct.](https://insightsengineering.github.io/teal.modules.clinical/CODE_OF_CONDUCT.html) 17 | options: 18 | - label: I agree to follow this project's Code of Conduct. 19 | required: true 20 | - type: checkboxes 21 | id: contributor-guidelines 22 | attributes: 23 | label: Contribution Guidelines 24 | description: By submitting this issue, you agree to follow our [Contribution Guidelines.](https://insightsengineering.github.io/teal.modules.clinical/CONTRIBUTING.html) 25 | options: 26 | - label: I agree to follow this project's Contribution Guidelines. 27 | required: true 28 | - type: checkboxes 29 | id: security-policy 30 | attributes: 31 | label: Security Policy 32 | description: By submitting this issue, you agree to follow our [Security Policy.](https://github.com/insightsengineering/teal.modules.clinical/security/policy) 33 | options: 34 | - label: I agree to follow this project's Security Policy. 35 | required: true 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: ❓ Question 3 | description: Question about usage or documentation 4 | title: "[Question]: <title>" 5 | labels: ["question"] 6 | body: 7 | - type: textarea 8 | attributes: 9 | label: What is your question? 10 | validations: 11 | required: true 12 | - type: checkboxes 13 | id: code-of-conduct 14 | attributes: 15 | label: Code of Conduct 16 | description: By submitting this issue, you agree to follow our [Code of Conduct.](https://insightsengineering.github.io/teal.modules.clinical/CODE_OF_CONDUCT.html) 17 | options: 18 | - label: I agree to follow this project's Code of Conduct. 19 | required: true 20 | - type: checkboxes 21 | id: contributor-guidelines 22 | attributes: 23 | label: Contribution Guidelines 24 | description: By submitting this issue, you agree to follow our [Contribution Guidelines.](https://insightsengineering.github.io/teal.modules.clinical/CONTRIBUTING.html) 25 | options: 26 | - label: I agree to follow this project's Contribution Guidelines. 27 | required: true 28 | - type: checkboxes 29 | id: security-policy 30 | attributes: 31 | label: Security Policy 32 | description: By submitting this issue, you agree to follow our [Security Policy.](https://github.com/insightsengineering/teal.modules.clinical/security/policy) 33 | options: 34 | - label: I agree to follow this project's Security Policy. 35 | required: true 36 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Pull Request 2 | 3 | <!--- Replace `#nnn` with your issue link for reference. --> 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 | default-landing-page: latest-tag 44 | additional-unit-test-report-directories: unit-test-report-non-cran 45 | deps-installation-method: setup-r-dependencies 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 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Release 🎈 3 | 4 | on: 5 | push: 6 | tags: 7 | - "v*" 8 | workflow_dispatch: 9 | 10 | jobs: 11 | docs: 12 | name: Pkgdown Docs 📚 13 | needs: release 14 | uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main 15 | secrets: 16 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 17 | with: 18 | default-landing-page: latest-tag 19 | deps-installation-method: setup-r-dependencies 20 | validation: 21 | name: R Package Validation report 📃 22 | needs: release 23 | uses: insightsengineering/r.pkg.template/.github/workflows/validation.yaml@main 24 | secrets: 25 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 26 | with: 27 | deps-installation-method: setup-r-dependencies 28 | release: 29 | name: Create release 🎉 30 | uses: insightsengineering/r.pkg.template/.github/workflows/release.yaml@main 31 | secrets: 32 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 33 | build: 34 | name: Build package and reports 🎁 35 | needs: [release, docs] 36 | uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@main 37 | secrets: 38 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 39 | with: 40 | additional-env-vars: | 41 | _R_CHECK_CRAN_INCOMING_REMOTE_=false 42 | additional-r-cmd-check-params: --as-cran 43 | enforce-note-blocklist: true 44 | note-blocklist: | 45 | checking dependencies in R code .* NOTE 46 | checking R code for possible problems .* NOTE 47 | checking examples .* NOTE 48 | checking Rd line widths .* NOTE 49 | checking top-level files .* NOTE 50 | unit-test-report-brand: >- 51 | https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/thumbs/teal.png 52 | deps-installation-method: setup-r-dependencies 53 | coverage: 54 | name: Coverage 📔 55 | needs: [release, docs] 56 | uses: insightsengineering/r.pkg.template/.github/workflows/test-coverage.yaml@main 57 | secrets: 58 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 59 | with: 60 | additional-env-vars: | 61 | NOT_CRAN=true 62 | deps-installation-method: setup-r-dependencies 63 | wasm: 64 | name: Build WASM packages 🧑‍🏭 65 | needs: release 66 | uses: insightsengineering/r.pkg.template/.github/workflows/wasm.yaml@main 67 | -------------------------------------------------------------------------------- /.github/workflows/scheduled.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Scheduled 🕰️ 3 | 4 | on: 5 | schedule: 6 | - cron: "45 3 * * 0" 7 | workflow_dispatch: 8 | inputs: 9 | chosen-workflow: 10 | description: | 11 | Select which workflow you'd like to run 12 | required: true 13 | type: choice 14 | default: rhub 15 | options: 16 | - rhub 17 | - dependency-test 18 | - branch-cleanup 19 | - revdepcheck 20 | 21 | jobs: 22 | dependency-test: 23 | if: > 24 | github.event_name == 'schedule' || ( 25 | github.event_name == 'workflow_dispatch' && 26 | inputs.chosen-workflow == 'dependency-test' 27 | ) 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | test-strategy: ["min_cohort", "min_isolated", "release", "max"] 32 | uses: insightsengineering/r.pkg.template/.github/workflows/verdepcheck.yaml@main 33 | name: Dependency Test - ${{ matrix.test-strategy }} 🔢 34 | secrets: 35 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 36 | GCHAT_WEBHOOK: ${{ secrets.GCHAT_WEBHOOK }} 37 | with: 38 | strategy: ${{ matrix.test-strategy }} 39 | additional-env-vars: | 40 | PKG_SYSREQS_DRY_RUN=true 41 | extra-deps: | 42 | matrixStats (>= 1.5.0);teal.slice (>= 0.5.1.9024) 43 | branch-cleanup: 44 | if: > 45 | github.event_name == 'schedule' || ( 46 | github.event_name == 'workflow_dispatch' && 47 | inputs.chosen-workflow == 'branch-cleanup' 48 | ) 49 | name: Branch Cleanup 🧹 50 | uses: insightsengineering/r.pkg.template/.github/workflows/branch-cleanup.yaml@main 51 | secrets: 52 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 53 | revdepcheck: 54 | if: > 55 | github.event_name == 'schedule' || ( 56 | github.event_name == 'workflow_dispatch' && 57 | inputs.chosen-workflow == 'revdepcheck' 58 | ) 59 | name: revdepcheck ↩️ 60 | uses: insightsengineering/r.pkg.template/.github/workflows/revdepcheck.yaml@main 61 | rhub: 62 | if: > 63 | github.event_name == 'schedule' || ( 64 | github.event_name == 'workflow_dispatch' && 65 | inputs.chosen-workflow == 'rhub' 66 | ) 67 | name: R-hub 🌐 68 | uses: insightsengineering/r.pkg.template/.github/workflows/rhub.yaml@main 69 | with: 70 | config: >- 71 | r-patched-linux-x86_64, 72 | r-release-linux-x86_64, 73 | r-devel-windows-x86_64, 74 | r-release-macos-arm64, 75 | r-release-macos-x86_64, 76 | r-release-windows-x86_64, 77 | r-oldrel-macos-arm64, 78 | r-oldrel-macos-x86_64, 79 | r-oldrel-windows-x86_64 80 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .httr-oauth 3 | .project 4 | .RData 5 | .Rhistory 6 | .Rproj.user 7 | .Ruserdata 8 | .settings/** 9 | *.html 10 | *.Rcheck 11 | *.rprof 12 | *.sas.txt 13 | *~ 14 | /.project 15 | devel/* 16 | doc 17 | docs 18 | inst/outputs/* 19 | logs 20 | Meta 21 | packrat/lib*/ 22 | temp 23 | temp_w 24 | templates/ 25 | tmp.* 26 | vignettes/*.html 27 | vignettes/*.md 28 | vignettes/*.R 29 | coverage.* 30 | tests/testthat/_snaps/**/*.new.md 31 | tests/testthat/_snaps/**/*.new.svg 32 | /doc/ 33 | /Meta/ 34 | -------------------------------------------------------------------------------- /.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_name_linter = object_name_linter( 6 | styles = c("snake_case", "symbols"), 7 | regexes = c(ANL = "^ANL_?[0-9A-Z_]*$", ADaM = "^r?AD[A-Z]{2,3}_?[0-9]*$") 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # All available hooks: https://pre-commit.com/hooks.html 3 | # R specific hooks: https://github.com/lorenzwalthert/precommit 4 | default_stages: [pre-commit] 5 | default_language_version: 6 | python: python3 7 | repos: 8 | - repo: https://github.com/lorenzwalthert/precommit 9 | rev: v0.4.3.9009 10 | hooks: 11 | - id: style-files 12 | name: Style code with `styler` 13 | args: [--style_pkg=styler, --style_fun=tidyverse_style, 14 | --cache-root=styler] 15 | - id: roxygenize 16 | name: Regenerate package documentation 17 | additional_dependencies: 18 | - insightsengineering/teal.slice # missing 19 | - davidgohel/flextable # Error: package 'flextable' is not available 20 | - davidgohel/gdtools # for flextable 21 | - insightsengineering/teal 22 | - insightsengineering/teal.transform 23 | - tern 24 | - broom 25 | - checkmate 26 | - dplyr 27 | - DT 28 | - ggplot2 29 | - ggrepel 30 | - grid 31 | - lifecycle 32 | - logger 33 | - methods 34 | - rlistings 35 | - rmarkdown 36 | - scales 37 | - shiny 38 | - shinyjs 39 | - shinyvalidate 40 | - shinyWidgets 41 | - stats 42 | - insightsengineering/roxy.shinylive 43 | - insightsengineering/teal.code 44 | - insightsengineering/teal.data 45 | - insightsengineering/teal.logger 46 | - insightsengineering/teal.reporter 47 | - insightsengineering/teal.widgets 48 | - insightsengineering/tern.gee 49 | - insightsengineering/tern.mmrm 50 | - insightsengineering/rtables 51 | - insightsengineering/rtables.officer 52 | - insightsengineering/formatters 53 | - utils 54 | - vistime 55 | - id: spell-check 56 | name: Check spelling with `spelling` 57 | exclude: > 58 | (?x)^( 59 | .*\.[rR]| 60 | .*\.css| 61 | .*\.jpg| 62 | .*\.js| 63 | .*\.png| 64 | .*\.py| 65 | .*\.RData| 66 | .*\.Rds| 67 | .*\.rds| 68 | .*\.Rproj| 69 | .*\.sh| 70 | .*\.svg| 71 | .*\.xml| 72 | (.*/|)\_pkgdown.y[a]?ml| 73 | (.*/|)\.covrignore| 74 | (.*/|)\.gitignore| 75 | (.*/|)\.gitlab-ci\.y[a]?ml| 76 | (.*/|)\.lintr| 77 | (.*/|)\.pre-commit-.*| 78 | (.*/|)\.Rbuildignore| 79 | (.*/|)\.Renviron| 80 | (.*/|)\.Rprofile| 81 | (.*/|)CODEOWNERS| 82 | (.*/|)DESCRIPTION| 83 | (.*/|)LICENSE| 84 | (.*/|)NAMESPACE| 85 | .*-package.Rd| 86 | (.*/|)staged_dependencies\.y[a]?ml| 87 | (.*/|)WORDLIST| 88 | \.github/.*\.y[a]?ml| 89 | data/.* 90 | )$ 91 | -------------------------------------------------------------------------------- /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 | http://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 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(as_num,character) 4 | S3method(as_num,default) 5 | S3method(as_num,factor) 6 | S3method(as_num,logical) 7 | S3method(as_num,numeric) 8 | export(add_expr) 9 | export(as_num) 10 | export(bracket_expr) 11 | export(call_concatenate) 12 | export(clean_description) 13 | export(color_lab_values) 14 | export(column_annotation_label) 15 | export(cs_to_des_filter) 16 | export(cs_to_des_select) 17 | export(cs_to_filter_spec) 18 | export(cs_to_select_spec) 19 | export(default_total_label) 20 | export(extract_input) 21 | export(get_var_labels) 22 | export(h_concat_expr) 23 | export(is.cs_or_des) 24 | export(pipe_expr) 25 | export(prepare_arm) 26 | export(prepare_arm_levels) 27 | export(set_default_total_label) 28 | export(split_choices) 29 | export(split_col_expr) 30 | export(split_interactions) 31 | export(tm_a_gee) 32 | export(tm_a_mmrm) 33 | export(tm_g_barchart_simple) 34 | export(tm_g_ci) 35 | export(tm_g_forest_rsp) 36 | export(tm_g_forest_tte) 37 | export(tm_g_ipp) 38 | export(tm_g_km) 39 | export(tm_g_lineplot) 40 | export(tm_g_pp_adverse_events) 41 | export(tm_g_pp_patient_timeline) 42 | export(tm_g_pp_therapy) 43 | export(tm_g_pp_vitals) 44 | export(tm_t_abnormality) 45 | export(tm_t_abnormality_by_worst_grade) 46 | export(tm_t_ancova) 47 | export(tm_t_binary_outcome) 48 | export(tm_t_coxreg) 49 | export(tm_t_events) 50 | export(tm_t_events_by_grade) 51 | export(tm_t_events_patyear) 52 | export(tm_t_events_summary) 53 | export(tm_t_exposure) 54 | export(tm_t_logistic) 55 | export(tm_t_mult_events) 56 | export(tm_t_pp_basic_info) 57 | export(tm_t_pp_laboratory) 58 | export(tm_t_pp_medical_history) 59 | export(tm_t_pp_prior_medication) 60 | export(tm_t_shift_by_arm) 61 | export(tm_t_shift_by_arm_by_worst) 62 | export(tm_t_shift_by_grade) 63 | export(tm_t_smq) 64 | export(tm_t_summary) 65 | export(tm_t_summary_by) 66 | export(tm_t_tte) 67 | import(shiny) 68 | import(teal) 69 | import(teal.transform) 70 | import(tern) 71 | importFrom(dplyr,"%>%") 72 | importFrom(dplyr,.data) 73 | importFrom(methods,is) 74 | importFrom(tern.gee,lsmeans) 75 | -------------------------------------------------------------------------------- /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 | "tmc_ex_adsl" 11 | 12 | #' @describeIn ex_data `ADAE` data 13 | #' 14 | "tmc_ex_adae" 15 | 16 | #' @describeIn ex_data `ADAETTE` data 17 | #' 18 | "tmc_ex_adaette" 19 | 20 | #' @describeIn ex_data `ADCM` data 21 | #' 22 | "tmc_ex_adcm" 23 | 24 | #' @describeIn ex_data `ADEG` data 25 | #' 26 | "tmc_ex_adeg" 27 | 28 | #' @describeIn ex_data `ADEX` data 29 | #' 30 | "tmc_ex_adex" 31 | 32 | #' @describeIn ex_data `ADLB` data 33 | #' 34 | "tmc_ex_adlb" 35 | 36 | #' @describeIn ex_data `ADMH` data 37 | #' 38 | "tmc_ex_admh" 39 | 40 | #' @describeIn ex_data `ADQS` data 41 | #' 42 | "tmc_ex_adqs" 43 | 44 | #' @describeIn ex_data `ADRS` data 45 | #' 46 | "tmc_ex_adrs" 47 | 48 | #' @describeIn ex_data `ADTTE` data 49 | #' 50 | "tmc_ex_adtte" 51 | 52 | #' @describeIn ex_data `ADVS` data 53 | #' 54 | "tmc_ex_advs" 55 | -------------------------------------------------------------------------------- /R/facet_grid_formula.R: -------------------------------------------------------------------------------- 1 | # This file contains functions that help with plotting in other modules 2 | 3 | #' Facetting formula `x_facet ~ y_facet` 4 | #' 5 | #' @description `r lifecycle::badge("stable")` 6 | #' Replaces `x_facet` or `y_facet` by . when empty character 7 | #' 8 | #' @md 9 | #' @param x_facet (`character(1)`)\cr 10 | #' name of x facet, if empty, will not facet along x. 11 | #' @param y_facet (`character(1)`)\cr 12 | #' name of y facet, if empty, will not facet along y. 13 | #' 14 | #' @return facet grid formula `formula(x_facet ~ y_facet)` 15 | #' 16 | #' @keywords internal 17 | #' 18 | facet_grid_formula <- function(x_facet, y_facet) { 19 | if (length(x_facet) == 0) x_facet <- "." 20 | if (length(y_facet) == 0) y_facet <- "." 21 | checkmate::assert_string(x_facet) 22 | checkmate::assert_string(y_facet) 23 | if (x_facet == y_facet) stop("'x_facet' and 'y_facet' must not be equal.") 24 | stats::as.formula(paste0(y_facet, " ~ ", x_facet)) # must invert it 25 | } 26 | -------------------------------------------------------------------------------- /R/labels.R: -------------------------------------------------------------------------------- 1 | #' Get full label, useful for annotating plots 2 | #' 3 | #' @param dataset (`data.frame`)\cr dataset 4 | #' @param column (`character`)\cr column to get label from 5 | #' @param omit_raw_name (`logical`)\cr omits the raw name in square brackets if label is found 6 | #' 7 | #' @return "Label `[Column name]`" if label exists, otherwise "Column name". 8 | #' 9 | #' @examples 10 | #' data <- mtcars 11 | #' column_annotation_label(data, "cyl") 12 | #' attr(data[["cyl"]], "label") <- "Cylinder" 13 | #' column_annotation_label(data, "cyl") 14 | #' column_annotation_label(data, "cyl", omit_raw_name = TRUE) 15 | #' column_annotation_label(tmc_ex_adsl, "ACTARM") 16 | #' @export 17 | column_annotation_label <- function(dataset, column, omit_raw_name = FALSE) { 18 | checkmate::assert_data_frame(dataset) 19 | checkmate::assert_string(column) 20 | checkmate::assert_flag(omit_raw_name) 21 | 22 | if (is.null(attr(dataset[[column]], "label"))) { 23 | column 24 | } else { 25 | col_label <- attr(dataset[[column]], "label") 26 | if (omit_raw_name) { 27 | col_label 28 | } else { 29 | sprintf("%s [%s]", col_label, column) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /R/string_ops.R: -------------------------------------------------------------------------------- 1 | #' Parse text input to numeric vector 2 | #' 3 | #' Generic to parse text into numeric vectors. This was initially designed 4 | #' for a robust interpretation of text input in teal modules. 5 | #' 6 | #' @param str (`vector`)\cr to extract numeric from. 7 | #' @details The function is intended to extract any numeric from a character 8 | #' string, factor levels, boolean and return a vector of numeric. 9 | #' 10 | #' @md 11 | #' 12 | #' @return As vector of numeric if directly parsed from `numeric` or boolean. 13 | #' A list of numeric if parsed from a character string, each character string 14 | #' associated with an list item. 15 | #' 16 | #' @examples 17 | #' dta <- list( 18 | #' character = c("text10,20.5letter30.!", "!-.40$$-50e5[", NA), 19 | #' factor = factor(c("]+60e-6, 7.7%%8L", "%90sep.100\"1L", NA_character_)), 20 | #' numeric = c(1, -5e+2, NA), 21 | #' logical = c(TRUE, FALSE, NA) 22 | #' ) 23 | #' lapply(dta, as_num) 24 | #' @export 25 | as_num <- function(str) { 26 | UseMethod("as_num") 27 | } 28 | 29 | #' @export 30 | #' @rdname as_num 31 | as_num.default <- function(str) { 32 | stop("No default implementation for `as_num.default`.") 33 | } 34 | 35 | #' @export 36 | #' @rdname as_num 37 | as_num.character <- function(str) { 38 | y <- regmatches( 39 | x = str, 40 | m = gregexpr( 41 | "[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?", 42 | str, 43 | perl = TRUE 44 | ) 45 | ) 46 | 47 | y <- lapply(y, as.numeric) 48 | y[unlist(lapply(y, length) == 0)] <- NA 49 | 50 | y 51 | } 52 | 53 | #' @export 54 | #' @rdname as_num 55 | as_num.numeric <- function(str) { 56 | str 57 | } 58 | 59 | #' @export 60 | #' @rdname as_num 61 | as_num.factor <- function(str) { 62 | y <- as.character(str) 63 | y <- as_num(y) 64 | y 65 | } 66 | 67 | #' @export 68 | #' @rdname as_num 69 | as_num.logical <- function(str) { 70 | y <- as.numeric(str) 71 | y 72 | } 73 | -------------------------------------------------------------------------------- /R/substitute_names.R: -------------------------------------------------------------------------------- 1 | #' Substitute in Quoted Expressions 2 | #' 3 | #' This version of substitute is needed because [substitute()] does not 4 | #' evaluate it's first argument, and it's often useful to be able to modify 5 | #' a quoted expression. 6 | #' 7 | #' @md 8 | #' @param qexpr (`language`)\cr a quoted expression. 9 | #' @param env (`environment` or `list`)\cr requested variable substitutions. 10 | #' 11 | #' @return The modified expression. 12 | #' @note This is simplified from the package `pryr` to avoid another dependency. 13 | #' @seealso [substitute_names()] 14 | #' 15 | #' @keywords internal 16 | #' 17 | substitute_q <- function(qexpr, env) { 18 | stopifnot(is.language(qexpr)) 19 | call <- substitute(substitute(qexpr, env), list(qexpr = qexpr)) 20 | eval(call) 21 | } 22 | 23 | #' Substitute Names in a Quoted Expression 24 | #' 25 | #' This function substitutes the names on both left- and right-hand sides in a quoted expression. 26 | #' In addition it can also do other standard substitutions on the right-hand side. 27 | #' 28 | #' @md 29 | #' @param expr (`language`)\cr an expression. 30 | #' @param names (named `list` of `name`)\cr requested name substitutions. 31 | #' @param others (named `list`)\cr requested other substitutions which will only happen on the 32 | #' right-hand side. 33 | #' 34 | #' @name substitute_names 35 | #' @return The modified expression. 36 | #' @seealso [substitute_q()] 37 | #' 38 | #' @keywords internal 39 | #' 40 | substitute_names <- function(expr, names, others = list()) { 41 | checkmate::assert_list(names, min.len = 1, names = "unique", types = "name") 42 | checkmate::assert_list(others, min.len = 0, names = "unique") 43 | checkmate::assert_names(names(names), disjunct.from = names(others)) 44 | 45 | expr <- substitute(expr) 46 | expr <- substitute_rhs(expr, c(names, others)) 47 | substitute_lhs_names(expr, names) 48 | } 49 | 50 | #' @md 51 | #' @describeIn substitute_names Helper function to just substitute the top-level names on the left-hand side in a 52 | #' quoted expression. 53 | #' @inheritParams substitute_q 54 | #' @keywords internal 55 | h_subst_lhs_names <- function(qexpr, names) { 56 | will_replace <- names(names) 57 | to_replace <- names(qexpr) 58 | matches <- match(x = to_replace, table = will_replace) 59 | which_found <- which(!is.na(matches)) 60 | names_as_strings <- sapply(names, as.character) 61 | names(qexpr)[which_found] <- names_as_strings[matches[which_found]] 62 | qexpr 63 | } 64 | 65 | #' @md 66 | #' @describeIn substitute_names recursively substitutes all names on the left-hand sides in a quoted expression. 67 | #' @inheritParams substitute_q 68 | #' @keywords internal 69 | substitute_lhs_names <- function(qexpr, names) { 70 | if (length(qexpr) == 1L) { 71 | return(qexpr) 72 | } 73 | qexpr <- h_subst_lhs_names(qexpr, names) 74 | for (i in seq_along(qexpr)) { 75 | qexpr[[i]] <- substitute_lhs_names(qexpr[[i]], names) 76 | } 77 | qexpr 78 | } 79 | 80 | #' @md 81 | #' @describeIn substitute_names substitutes on the right-hand side in a quoted expression. 82 | #' Note that this is just a synonym for [substitute_q()]. 83 | #' @inheritParams substitute_q 84 | #' @keywords internal 85 | substitute_rhs <- function(qexpr, env) { 86 | substitute_q(qexpr, env) 87 | } 88 | -------------------------------------------------------------------------------- /R/teal.modules.clinical.R: -------------------------------------------------------------------------------- 1 | #' `teal` Modules for Standard Clinical Outputs 2 | #' 3 | #' Provides teal modules for the standard clinical trials outputs. 4 | #' The teal modules add an encoding panel to interactively change the encodings within teal. 5 | #' 6 | "_PACKAGE" 7 | 8 | #' @import shiny 9 | #' @import teal 10 | #' @import teal.transform 11 | #' @import tern 12 | #' @importFrom dplyr %>% .data 13 | #' @importFrom methods is 14 | #' @importFrom tern.gee lsmeans 15 | 16 | # We need this to avoid R CMD check warning about missing global definitions. 17 | utils::globalVariables(c( 18 | "arm_var", 19 | "column_name", 20 | "n_column_name", 21 | "new_arm_ref_comp", 22 | "new_comp_arm", 23 | "usubjid", 24 | "x_var" 25 | )) 26 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(libname, pkgname) { 2 | teal.logger::register_logger(namespace = "teal.modules.clinical") 3 | teal.logger::register_handlers("teal.modules.clinical") 4 | tern::set_default_na_str("<Missing>") 5 | } 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | --- 2 | url: https://insightsengineering.github.io/teal.modules.clinical 3 | 4 | template: 5 | package: nesttemplate 6 | 7 | navbar: 8 | structure: 9 | left: [intro, reference, articles, tutorials, news, reports] 10 | right: [search, github] 11 | components: 12 | reports: 13 | text: Reports 14 | menu: 15 | - text: Coverage report 16 | href: coverage-report/ 17 | - text: Unit test report 18 | href: unit-test-report/ 19 | - text: Non-CRAN unit test report 20 | href: unit-test-report-non-cran/ 21 | github: 22 | icon: fa-github 23 | href: https://github.com/insightsengineering/teal.modules.clinical 24 | 25 | reference: 26 | - title: 27 | contents: 28 | - teal.modules.clinical 29 | - title: Tables 30 | contents: 31 | - starts_with("tm_t_") 32 | - title: Graphs 33 | contents: 34 | - starts_with("tm_g_") 35 | - title: General analyses 36 | contents: 37 | - starts_with("tm_a_") 38 | - title: Patient profile modules 39 | contents: 40 | - starts_with("tm_[g|t]_pp_") 41 | - title: Helper functions 42 | contents: 43 | - add_expr 44 | - as_num 45 | - bracket_expr 46 | - call_concatenate 47 | - clean_description 48 | - color_lab_values 49 | - column_annotation_label 50 | - cs_to_des_filter 51 | - cs_to_des_select 52 | - cs_to_filter_spec 53 | - cs_to_select_spec 54 | - default_total_label 55 | - extract_input 56 | - get_var_labels 57 | - h_concat_expr 58 | - is.cs_or_des 59 | - pipe_expr 60 | - prepare_arm 61 | - prepare_arm_levels 62 | - split_choices 63 | - split_col_expr 64 | - split_interactions 65 | - title: Data 66 | desc: Data included in the package. 67 | contents: 68 | - starts_with("ex_") 69 | -------------------------------------------------------------------------------- /data/tmc_ex_adae.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adae.rda -------------------------------------------------------------------------------- /data/tmc_ex_adaette.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adaette.rda -------------------------------------------------------------------------------- /data/tmc_ex_adcm.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adcm.rda -------------------------------------------------------------------------------- /data/tmc_ex_adeg.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adeg.rda -------------------------------------------------------------------------------- /data/tmc_ex_adex.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adex.rda -------------------------------------------------------------------------------- /data/tmc_ex_adlb.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adlb.rda -------------------------------------------------------------------------------- /data/tmc_ex_admh.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_admh.rda -------------------------------------------------------------------------------- /data/tmc_ex_adqs.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adqs.rda -------------------------------------------------------------------------------- /data/tmc_ex_adrs.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adrs.rda -------------------------------------------------------------------------------- /data/tmc_ex_adsl.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adsl.rda -------------------------------------------------------------------------------- /data/tmc_ex_adtte.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_adtte.rda -------------------------------------------------------------------------------- /data/tmc_ex_advs.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/teal.modules.clinical/3d64b46c6510c56643f9c4386c23b5098f00a121/data/tmc_ex_advs.rda -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | ADaM 2 | AE 3 | ANCOVA 4 | ElementaryTable 5 | Facetting 6 | Forkers 7 | GDSR 8 | Getter 9 | Hoffmann 10 | Kaplan 11 | MMRM 12 | MedDRA 13 | NSE 14 | ORCID 15 | Rua 16 | SMQ 17 | Shinylive 18 | TLG 19 | TableTree 20 | UI 21 | Univariable 22 | datatables 23 | de 24 | funder 25 | ggplot 26 | lsmeans 27 | pre 28 | preselected 29 | responder 30 | responders 31 | univariable 32 | unstratified 33 | -------------------------------------------------------------------------------- /inst/css/custom.css: -------------------------------------------------------------------------------- 1 | /* teal.modules.clinical custom css */ 2 | 3 | .bg-orange { 4 | background-color: orange; 5 | } 6 | 7 | .text-dark { 8 | color: black; 9 | } 10 | 11 | .overflow-y-scroll { 12 | overflow-y:scroll 13 | } 14 | 15 | .max-h-250 { 16 | max-height: 250px 17 | } 18 | 19 | .mb-4 { 20 | margin-bottom: 1rem; 21 | } 22 | 23 | .btn.disabled { 24 | color: grey; 25 | background-color: white; 26 | } 27 | -------------------------------------------------------------------------------- /man-roxygen/author_liaoc10.R: -------------------------------------------------------------------------------- 1 | #' @author Chendi Liao (liaoc10) \email{chendi.liao@roche.com} 2 | -------------------------------------------------------------------------------- /man-roxygen/author_song24.R: -------------------------------------------------------------------------------- 1 | #' @author Yuyao Song (songy24) \email{yuyao.song@roche.com} 2 | -------------------------------------------------------------------------------- /man-roxygen/author_waddella.R: -------------------------------------------------------------------------------- 1 | #' @author Adrian Waddell (waddella) \email{adrian.waddell@roche.com} 2 | -------------------------------------------------------------------------------- /man-roxygen/author_wangh107.R: -------------------------------------------------------------------------------- 1 | #' @author Heng Wang (wangh107) \email{wang.heng@gene.com} 2 | -------------------------------------------------------------------------------- /man-roxygen/param_plot_height.R: -------------------------------------------------------------------------------- 1 | #' @param plot_height plot height specification 2 | -------------------------------------------------------------------------------- /man/add_expr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{add_expr} 4 | \alias{add_expr} 5 | \title{Expression List} 6 | \usage{ 7 | add_expr(expr_ls, new_expr) 8 | } 9 | \arguments{ 10 | \item{expr_ls}{(\code{list} of \code{call})\cr the list to which a new expression 11 | should be added.} 12 | 13 | \item{new_expr}{(\code{call})\cr the new expression to add.} 14 | } 15 | \value{ 16 | a \code{list} of \code{call}. 17 | } 18 | \description{ 19 | Add a new expression to a list (of expressions). 20 | } 21 | \details{ 22 | Offers a stricter control to add new expressions to an existing 23 | list. The list of expressions can be later used to generate a pipeline, 24 | for instance with \code{pipe_expr}. 25 | } 26 | \examples{ 27 | library(rtables) 28 | 29 | lyt <- list() 30 | lyt <- add_expr(lyt, substitute(basic_table())) 31 | lyt <- add_expr( 32 | lyt, substitute(split_cols_by(var = arm), env = list(armcd = "ARMCD")) 33 | ) 34 | lyt <- add_expr( 35 | lyt, 36 | substitute( 37 | test_proportion_diff( 38 | vars = "rsp", method = "cmh", variables = list(strata = "strata") 39 | ) 40 | ) 41 | ) 42 | lyt <- add_expr(lyt, quote(build_table(df = dta))) 43 | pipe_expr(lyt) 44 | } 45 | -------------------------------------------------------------------------------- /man/arm_ref_comp_observer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/arm_ref_comp.R 3 | \name{arm_ref_comp_observer} 4 | \alias{arm_ref_comp_observer} 5 | \title{Observer for Treatment reference variable} 6 | \usage{ 7 | arm_ref_comp_observer( 8 | session, 9 | input, 10 | output, 11 | id_ref = "Ref", 12 | id_comp = "Comp", 13 | id_arm_var, 14 | data, 15 | arm_ref_comp, 16 | module, 17 | on_off = reactive(TRUE), 18 | input_id = "buckets", 19 | output_id = "arms_buckets" 20 | ) 21 | } 22 | \arguments{ 23 | \item{session}{(\code{environment})\cr shiny session} 24 | 25 | \item{input}{(\code{character})\cr shiny input} 26 | 27 | \item{output}{(\code{character})\cr shiny input} 28 | 29 | \item{id_ref}{(\code{character})\cr id of reference Treatment input UI element} 30 | 31 | \item{id_comp}{(\code{character})\cr id of comparison group input UI element} 32 | 33 | \item{id_arm_var}{(\code{character})\cr id of Treatment variable input UI element} 34 | 35 | \item{data}{(\code{reactive} or \code{data.frame})\cr dataset used to validate Treatment reference inputs and 36 | set \code{id_ref} input.} 37 | 38 | \item{arm_ref_comp}{(\code{unknown})\cr Treatment reference and compare variables provided as a 39 | nested list where each Treatment variable corresponds a list specifying the default levels for the 40 | reference and comparison treatments.} 41 | 42 | \item{module}{(\code{character})\cr name of the module where this is called (this is only used 43 | to produce more informative error messages)} 44 | 45 | \item{on_off}{(\code{logical})\cr A reactive that can be used to 46 | stop the whole observer if \code{FALSE}.} 47 | 48 | \item{input_id}{(\code{character})\cr unique id that the buckets will be referenced with.} 49 | 50 | \item{output_id}{(\code{character})\cr name of the UI id that the output will be written to.} 51 | } 52 | \value{ 53 | Returns a \code{shinyvalidate::InputValidator} which checks that there is at least one reference 54 | and comparison arm 55 | } 56 | \description{ 57 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} 58 | Updates the reference and comparison Treatments when the selected Treatment variable changes 59 | } 60 | \keyword{internal} 61 | -------------------------------------------------------------------------------- /man/as_num.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/string_ops.R 3 | \name{as_num} 4 | \alias{as_num} 5 | \alias{as_num.default} 6 | \alias{as_num.character} 7 | \alias{as_num.numeric} 8 | \alias{as_num.factor} 9 | \alias{as_num.logical} 10 | \title{Parse text input to numeric vector} 11 | \usage{ 12 | as_num(str) 13 | 14 | \method{as_num}{default}(str) 15 | 16 | \method{as_num}{character}(str) 17 | 18 | \method{as_num}{numeric}(str) 19 | 20 | \method{as_num}{factor}(str) 21 | 22 | \method{as_num}{logical}(str) 23 | } 24 | \arguments{ 25 | \item{str}{(\code{vector})\cr to extract numeric from.} 26 | } 27 | \value{ 28 | As vector of numeric if directly parsed from \code{numeric} or boolean. 29 | A list of numeric if parsed from a character string, each character string 30 | associated with an list item. 31 | } 32 | \description{ 33 | Generic to parse text into numeric vectors. This was initially designed 34 | for a robust interpretation of text input in teal modules. 35 | } 36 | \details{ 37 | The function is intended to extract any numeric from a character 38 | string, factor levels, boolean and return a vector of numeric. 39 | } 40 | \examples{ 41 | dta <- list( 42 | character = c("text10,20.5letter30.!", "!-.40$$-50e5[", NA), 43 | factor = factor(c("]+60e-6, 7.7\%\%8L", "\%90sep.100\"1L", NA_character_)), 44 | numeric = c(1, -5e+2, NA), 45 | logical = c(TRUE, FALSE, NA) 46 | ) 47 | lapply(dta, as_num) 48 | } 49 | -------------------------------------------------------------------------------- /man/bracket_expr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{bracket_expr} 4 | \alias{bracket_expr} 5 | \title{Expressions in Brackets} 6 | \usage{ 7 | bracket_expr(exprs) 8 | } 9 | \arguments{ 10 | \item{exprs}{(\code{list} of \code{call})\cr expressions to concatenate into 11 | a single \emph{bracketed} expression.} 12 | } 13 | \value{ 14 | a \verb{\{} object. See \code{\link[base:Paren]{base::Paren()}} for details. 15 | } 16 | \description{ 17 | Groups several expressions in a single \emph{bracketed} expression. 18 | } 19 | \examples{ 20 | adsl <- tmc_ex_adsl 21 | adrs <- tmc_ex_adrs 22 | 23 | expr1 <- substitute( 24 | expr = anl <- subset(df, PARAMCD == param), 25 | env = list(df = as.name("adrs"), param = "INVET") 26 | ) 27 | expr2 <- substitute(expr = anl$rsp_lab <- d_onco_rsp_label(anl$AVALC)) 28 | expr3 <- substitute( 29 | expr = { 30 | anl$is_rsp <- anl$rsp_lab \%in\% 31 | c("Complete Response (CR)", "Partial Response (PR)") 32 | } 33 | ) 34 | 35 | res <- bracket_expr(list(expr1, expr2, expr3)) 36 | eval(res) 37 | table(anl$rsp_lab, anl$is_rsp) 38 | 39 | } 40 | -------------------------------------------------------------------------------- /man/call_concatenate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{call_concatenate} 4 | \alias{call_concatenate} 5 | \title{Concatenate expressions via a binary operator} 6 | \usage{ 7 | call_concatenate(args, bin_op = "+") 8 | } 9 | \arguments{ 10 | \item{args}{arguments to concatenate with operator} 11 | 12 | \item{bin_op}{binary operator to concatenate it with} 13 | } 14 | \value{ 15 | a \code{call} 16 | } 17 | \description{ 18 | e.g. combine with \code{+} for \code{ggplot} without introducing parentheses due to associativity 19 | } 20 | \examples{ 21 | library(ggplot2) 22 | 23 | # What we want to achieve 24 | call("+", quote(f), quote(g)) 25 | call("+", quote(f), call("+", quote(g), quote(h))) # parentheses not wanted 26 | call("+", call("+", quote(f), quote(g)), quote(h)) # as expected without unnecessary parentheses 27 | Reduce(function(existing, new) call("+", existing, new), list(quote(f), quote(g), quote(h))) 28 | 29 | # how we do it 30 | call_concatenate(list(quote(f), quote(g), quote(h))) 31 | call_concatenate(list(quote(f))) 32 | call_concatenate(list()) 33 | call_concatenate( 34 | list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg)))) 35 | ) 36 | 37 | eval( 38 | call_concatenate( 39 | list(quote(ggplot(mtcars)), quote(geom_point(aes(wt, mpg)))) 40 | ) 41 | ) 42 | 43 | } 44 | -------------------------------------------------------------------------------- /man/check_arm_ref_comp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/arm_ref_comp.R 3 | \name{check_arm_ref_comp} 4 | \alias{check_arm_ref_comp} 5 | \title{Check if the Treatment variable is reference or compare} 6 | \usage{ 7 | check_arm_ref_comp(x, df_to_check, module) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{character})\cr Name of the variable} 11 | 12 | \item{df_to_check}{(\code{data.frame})\cr table to check} 13 | 14 | \item{module}{(\code{character})\cr teal module the ref and comp are called in} 15 | } 16 | \value{ 17 | \code{TRUE} or \code{FALSE} whether the variable is in ref or comp 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 | \keyword{internal} 23 | -------------------------------------------------------------------------------- /man/clean_description.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{clean_description} 4 | \alias{clean_description} 5 | \title{Clean up categorical variable description} 6 | \usage{ 7 | clean_description(x) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{character})\cr vector with categories descriptions.} 11 | } 12 | \value{ 13 | a string 14 | } 15 | \description{ 16 | Cleaning categorical variable descriptions before presenting. 17 | } 18 | \examples{ 19 | clean_description("Level A (other text)") 20 | clean_description("A long string that should be shortened") 21 | 22 | } 23 | -------------------------------------------------------------------------------- /man/color_lab_values.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{color_lab_values} 4 | \alias{color_lab_values} 5 | \title{Mapping function for Laboratory Table} 6 | \usage{ 7 | color_lab_values( 8 | x, 9 | classes = c("HIGH", "NORMAL", "LOW"), 10 | colors = list(HIGH = "red", NORMAL = "grey", LOW = "blue"), 11 | default_color = "black", 12 | icons = list(HIGH = "glyphicon glyphicon-arrow-up", LOW = 13 | "glyphicon glyphicon-arrow-down") 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{(\code{character})\cr vector with elements under the format (\verb{value level}).} 18 | 19 | \item{classes}{(\code{character})\cr classes vector.} 20 | 21 | \item{colors}{(\code{list})\cr color per class.} 22 | 23 | \item{default_color}{(\code{character})\cr default color.} 24 | 25 | \item{icons}{(\code{list})\cr certain icons per level.} 26 | } 27 | \value{ 28 | a character vector where each element is a formatted HTML tag corresponding to 29 | a value in \code{x}. 30 | } 31 | \description{ 32 | Map value and level characters to values with with proper html tags, colors and icons. 33 | } 34 | \examples{ 35 | color_lab_values(c("LOW", "LOW", "HIGH", "NORMAL", "HIGH")) 36 | 37 | } 38 | -------------------------------------------------------------------------------- /man/column_annotation_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/labels.R 3 | \name{column_annotation_label} 4 | \alias{column_annotation_label} 5 | \title{Get full label, useful for annotating plots} 6 | \usage{ 7 | column_annotation_label(dataset, column, omit_raw_name = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataset}{(\code{data.frame})\cr dataset} 11 | 12 | \item{column}{(\code{character})\cr column to get label from} 13 | 14 | \item{omit_raw_name}{(\code{logical})\cr omits the raw name in square brackets if label is found} 15 | } 16 | \value{ 17 | "Label \verb{[Column name]}" if label exists, otherwise "Column name". 18 | } 19 | \description{ 20 | Get full label, useful for annotating plots 21 | } 22 | \examples{ 23 | data <- mtcars 24 | column_annotation_label(data, "cyl") 25 | attr(data[["cyl"]], "label") <- "Cylinder" 26 | column_annotation_label(data, "cyl") 27 | column_annotation_label(data, "cyl", omit_raw_name = TRUE) 28 | column_annotation_label(tmc_ex_adsl, "ACTARM") 29 | } 30 | -------------------------------------------------------------------------------- /man/control_tte.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_tte.R 3 | \name{control_tte} 4 | \alias{control_tte} 5 | \title{Control Function for Time-To-Event teal Module} 6 | \usage{ 7 | control_tte( 8 | surv_time = list(conf_level = 0.95, conf_type = "plain", quantiles = c(0.25, 0.75)), 9 | coxph = list(pval_method = "log-rank", ties = "efron", conf_level = 0.95), 10 | surv_timepoint = control_surv_timepoint(conf_level = 0.95, conf_type = c("plain", 11 | "none", "log", "log-log")) 12 | ) 13 | } 14 | \arguments{ 15 | \item{surv_time}{(\code{list})\cr control parameters for \code{survfit} model. See \code{\link[tern:control_surv_time]{tern::control_surv_time()}} for details.} 16 | 17 | \item{coxph}{(\code{list})\cr control parameters for Cox-PH model. See \code{\link[tern:control_coxph]{tern::control_coxph()}} for details.} 18 | 19 | \item{surv_timepoint}{(\code{list})\cr control parameters for \code{survfit} model at time point. See 20 | \code{\link[tern:control_surv_timepoint]{tern::control_surv_timepoint()}} for details.} 21 | } 22 | \description{ 23 | Controls the arguments for Cox regression and survival analysis results. 24 | } 25 | \seealso{ 26 | \code{\link[=template_tte]{template_tte()}}, \code{\link[=tm_t_tte]{tm_t_tte()}} 27 | } 28 | \keyword{internal} 29 | -------------------------------------------------------------------------------- /man/cs_to_des_filter.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cs_to_des_filter} 4 | \alias{cs_to_des_filter} 5 | \title{Convert choices_selected to data_extract_spec with only filter_spec} 6 | \usage{ 7 | cs_to_des_filter( 8 | cs, 9 | dataname, 10 | multiple = FALSE, 11 | include_vars = FALSE, 12 | label = "Filter by" 13 | ) 14 | } 15 | \arguments{ 16 | \item{cs}{(\code{choices_selected})\cr object to be transformed. See \code{\link[teal.transform:choices_selected]{teal.transform::choices_selected()}} for details.} 17 | 18 | \item{dataname}{(\code{character})\cr name of the data} 19 | 20 | \item{multiple}{(\code{logical})\cr Whether multiple values shall be allowed in the 21 | shiny \code{\link[shiny:selectInput]{shiny::selectInput()}}.} 22 | 23 | \item{include_vars}{(\code{flag})\cr whether to include the filter variables as fixed selection 24 | in the result. This can be useful for preserving for reuse in \code{rtables} code e.g.} 25 | 26 | \item{label}{(\code{character})\cr Label to print over the selection field. For no label, set to \code{NULL}.} 27 | } 28 | \value{ 29 | (\code{\link[teal.transform:data_extract_spec]{teal.transform::data_extract_spec()}}) 30 | } 31 | \description{ 32 | Convert choices_selected to data_extract_spec with only filter_spec 33 | } 34 | -------------------------------------------------------------------------------- /man/cs_to_des_select.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cs_to_des_select} 4 | \alias{cs_to_des_select} 5 | \title{Convert choices_selected to data_extract_spec with only select_spec} 6 | \usage{ 7 | cs_to_des_select( 8 | cs, 9 | dataname, 10 | multiple = FALSE, 11 | ordered = FALSE, 12 | label = "Select" 13 | ) 14 | } 15 | \arguments{ 16 | \item{cs}{(\code{choices_selected})\cr object to be transformed. See \code{\link[teal.transform:choices_selected]{teal.transform::choices_selected()}} for details.} 17 | 18 | \item{dataname}{(\code{character})\cr name of the data} 19 | 20 | \item{multiple}{(\code{logical})\cr Whether multiple values shall be allowed in the 21 | shiny \code{\link[shiny:selectInput]{shiny::selectInput()}}.} 22 | 23 | \item{ordered}{(\code{logical(1)})\cr Flags whether selection order should be tracked.} 24 | 25 | \item{label}{(\code{character})\cr Label to print over the selection field. For no label, set to \code{NULL}.} 26 | } 27 | \value{ 28 | (\code{\link[teal.transform:data_extract_spec]{teal.transform::data_extract_spec()}}) 29 | } 30 | \description{ 31 | Convert choices_selected to data_extract_spec with only select_spec 32 | } 33 | -------------------------------------------------------------------------------- /man/cs_to_filter_spec.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cs_to_filter_spec} 4 | \alias{cs_to_filter_spec} 5 | \title{Convert choices_selected to filter_spec} 6 | \usage{ 7 | cs_to_filter_spec(cs, multiple = FALSE, label = "Filter by") 8 | } 9 | \arguments{ 10 | \item{cs}{(\code{choices_selected})\cr object to be transformed. See \code{\link[teal.transform:choices_selected]{teal.transform::choices_selected()}} for details.} 11 | 12 | \item{multiple}{(\code{logical})\cr Whether multiple values shall be allowed in the 13 | shiny \code{\link[shiny:selectInput]{shiny::selectInput()}}.} 14 | 15 | \item{label}{(\code{character})\cr Label to print over the selection field. For no label, set to \code{NULL}.} 16 | } 17 | \value{ 18 | (\code{\link[teal.transform:filter_spec]{teal.transform::filter_spec()}}) 19 | } 20 | \description{ 21 | Convert choices_selected to filter_spec 22 | } 23 | -------------------------------------------------------------------------------- /man/cs_to_select_spec.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cs_to_select_spec} 4 | \alias{cs_to_select_spec} 5 | \title{Convert choices_selected to select_spec} 6 | \usage{ 7 | cs_to_select_spec(cs, multiple = FALSE, ordered = FALSE, label = "Select") 8 | } 9 | \arguments{ 10 | \item{cs}{(\code{choices_selected})\cr object to be transformed. See \code{\link[teal.transform:choices_selected]{teal.transform::choices_selected()}} for details.} 11 | 12 | \item{multiple}{(\code{logical})\cr Whether multiple values shall be allowed in the 13 | shiny \code{\link[shiny:selectInput]{shiny::selectInput()}}.} 14 | 15 | \item{ordered}{(\code{logical(1)})\cr Flags whether selection order should be tracked.} 16 | 17 | \item{label}{(\code{character})\cr Label to print over the selection field. For no label, set to \code{NULL}.} 18 | } 19 | \value{ 20 | (\code{select_spec}) 21 | } 22 | \description{ 23 | Convert choices_selected to select_spec 24 | } 25 | -------------------------------------------------------------------------------- /man/default_total_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{default_total_label} 4 | \alias{default_total_label} 5 | \alias{set_default_total_label} 6 | \title{Default string for total column label} 7 | \usage{ 8 | default_total_label() 9 | 10 | set_default_total_label(total_label) 11 | } 12 | \arguments{ 13 | \item{total_label}{(\code{string})\cr Single string value to set in the R environment options as 14 | the default label to use for the "total" column. Use \code{getOption("tmc_default_total_label")} to 15 | check the current value set in the R environment (defaults to \code{"All Patients"} if not set).} 16 | } 17 | \value{ 18 | \itemize{ 19 | \item \code{default_total_label} returns the current value if an R environment option has been set 20 | for \code{"tmc_default_total_label"}, or \code{"All Patients"} otherwise. 21 | } 22 | 23 | \itemize{ 24 | \item \code{set_default_total_label} has no return value. 25 | } 26 | } 27 | \description{ 28 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} 29 | 30 | The default string used as a label for the "total" column. This value is used as the default 31 | value for the \code{total_label} argument throughout the \code{teal.modules.clinical} package. If not specified 32 | for each module by the user via the \code{total_label} argument, or in the R environment options via 33 | \code{\link[=set_default_total_label]{set_default_total_label()}}, then \code{"All Patients"} is used. 34 | } 35 | \section{Functions}{ 36 | \itemize{ 37 | \item \code{default_total_label()}: Getter for default total column label. 38 | 39 | \item \code{set_default_total_label()}: Setter for default total column label. Sets the 40 | option \code{"tmc_default_total_label"} within the R environment. 41 | 42 | }} 43 | \examples{ 44 | # Default settings 45 | default_total_label() 46 | getOption("tmc_default_total_label") 47 | 48 | # Set custom value 49 | set_default_total_label("All Patients") 50 | 51 | # Settings after value has been set 52 | default_total_label() 53 | getOption("tmc_default_total_label") 54 | 55 | } 56 | -------------------------------------------------------------------------------- /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{tmc_ex_adsl} 7 | \alias{tmc_ex_adae} 8 | \alias{tmc_ex_adaette} 9 | \alias{tmc_ex_adcm} 10 | \alias{tmc_ex_adeg} 11 | \alias{tmc_ex_adex} 12 | \alias{tmc_ex_adlb} 13 | \alias{tmc_ex_admh} 14 | \alias{tmc_ex_adqs} 15 | \alias{tmc_ex_adrs} 16 | \alias{tmc_ex_adtte} 17 | \alias{tmc_ex_advs} 18 | \title{Simulated \code{CDISC} Data for Examples} 19 | \format{ 20 | \code{rds} (\code{data.frame}) 21 | 22 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 200 rows and 26 columns. 23 | 24 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 541 rows and 51 columns. 25 | 26 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1800 rows and 35 columns. 27 | 28 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 512 rows and 45 columns. 29 | 30 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 5200 rows and 48 columns. 31 | 32 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 200 rows and 37 columns. 33 | 34 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 3000 rows and 58 columns. 35 | 36 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1077 rows and 33 columns. 37 | 38 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 7000 rows and 36 columns. 39 | 40 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1600 rows and 34 columns. 41 | 42 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1000 rows and 34 columns. 43 | 44 | An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 8400 rows and 34 columns. 45 | } 46 | \usage{ 47 | tmc_ex_adsl 48 | 49 | tmc_ex_adae 50 | 51 | tmc_ex_adaette 52 | 53 | tmc_ex_adcm 54 | 55 | tmc_ex_adeg 56 | 57 | tmc_ex_adex 58 | 59 | tmc_ex_adlb 60 | 61 | tmc_ex_admh 62 | 63 | tmc_ex_adqs 64 | 65 | tmc_ex_adrs 66 | 67 | tmc_ex_adtte 68 | 69 | tmc_ex_advs 70 | } 71 | \description{ 72 | Simulated \code{CDISC} Data for Examples 73 | } 74 | \section{Functions}{ 75 | \itemize{ 76 | \item \code{tmc_ex_adsl}: \code{ADSL} data 77 | 78 | \item \code{tmc_ex_adae}: \code{ADAE} data 79 | 80 | \item \code{tmc_ex_adaette}: \code{ADAETTE} data 81 | 82 | \item \code{tmc_ex_adcm}: \code{ADCM} data 83 | 84 | \item \code{tmc_ex_adeg}: \code{ADEG} data 85 | 86 | \item \code{tmc_ex_adex}: \code{ADEX} data 87 | 88 | \item \code{tmc_ex_adlb}: \code{ADLB} data 89 | 90 | \item \code{tmc_ex_admh}: \code{ADMH} data 91 | 92 | \item \code{tmc_ex_adqs}: \code{ADQS} data 93 | 94 | \item \code{tmc_ex_adrs}: \code{ADRS} data 95 | 96 | \item \code{tmc_ex_adtte}: \code{ADTTE} data 97 | 98 | \item \code{tmc_ex_advs}: \code{ADVS} data 99 | 100 | }} 101 | \keyword{datasets} 102 | -------------------------------------------------------------------------------- /man/extract_input.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{extract_input} 4 | \alias{extract_input} 5 | \title{Extracts html id for \code{data_extract_ui}} 6 | \usage{ 7 | extract_input(varname, dataname, filter = FALSE) 8 | } 9 | \arguments{ 10 | \item{varname}{(\code{character})\cr 11 | the original html id. This should be retrieved with \code{ns("original id")} in the UI function 12 | or \code{session$ns("original id")}/"original id" in the server function.} 13 | 14 | \item{dataname}{(\code{character})\cr 15 | \code{dataname} from data_extract input. 16 | This might be retrieved like \code{data_extract_spec(...)[[1]]$dataname}.} 17 | 18 | \item{filter}{(\code{logical}) optional,\cr 19 | if the connected \code{extract_data_spec} has objects passed to its \code{filter} argument} 20 | } 21 | \value{ 22 | a string 23 | } 24 | \description{ 25 | The \code{data_extract_ui} is located under extended html id. We could not use \code{ns("original id")} 26 | for reference, as it is extended with specific suffixes. 27 | } 28 | \examples{ 29 | extract_input("ARM", "ADSL") 30 | 31 | } 32 | -------------------------------------------------------------------------------- /man/facet_grid_formula.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/facet_grid_formula.R 3 | \name{facet_grid_formula} 4 | \alias{facet_grid_formula} 5 | \title{Facetting formula \code{x_facet ~ y_facet}} 6 | \usage{ 7 | facet_grid_formula(x_facet, y_facet) 8 | } 9 | \arguments{ 10 | \item{x_facet}{(\code{character(1)})\cr 11 | name of x facet, if empty, will not facet along x.} 12 | 13 | \item{y_facet}{(\code{character(1)})\cr 14 | name of y facet, if empty, will not facet along y.} 15 | } 16 | \value{ 17 | facet grid formula \code{formula(x_facet ~ y_facet)} 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 | Replaces \code{x_facet} or \code{y_facet} by . when empty character 22 | } 23 | \keyword{internal} 24 | -------------------------------------------------------------------------------- /man/get_g_forest_obj_var_name.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{get_g_forest_obj_var_name} 4 | \alias{get_g_forest_obj_var_name} 5 | \title{Utility function for extracting \code{paramcd} for forest plots} 6 | \usage{ 7 | get_g_forest_obj_var_name(paramcd, input, filter_idx = 1) 8 | } 9 | \arguments{ 10 | \item{paramcd}{\code{\link[teal.transform:data_extract_spec]{teal.transform::data_extract_spec()}} 11 | variable value designating the studied parameter.} 12 | 13 | \item{input}{shiny app input} 14 | 15 | \item{filter_idx}{filter section index (default 1)} 16 | } 17 | \description{ 18 | Utility function for extracting \code{paramcd} for forest plots 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/get_paramcd_label.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{get_paramcd_label} 4 | \alias{get_paramcd_label} 5 | \title{Extract the associated parameter value for \code{paramcd}} 6 | \usage{ 7 | get_paramcd_label(anl, paramcd) 8 | } 9 | \arguments{ 10 | \item{anl}{Analysis dataset} 11 | 12 | \item{paramcd}{\code{\link[teal.transform:data_extract_spec]{teal.transform::data_extract_spec()}} 13 | variable value designating the studied parameter.} 14 | } 15 | \description{ 16 | Utility function for extracting the parameter value that is associated 17 | with the \code{paramcd} value label. If there is no parameter value for 18 | the \code{paramcd} label, the \code{paramcd} value is returned. This is used 19 | for generating the title. 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/get_var_labels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{get_var_labels} 4 | \alias{get_var_labels} 5 | \title{Get variable labels} 6 | \usage{ 7 | get_var_labels(datasets, dataname, vars) 8 | } 9 | \arguments{ 10 | \item{datasets}{(\code{teal::FilteredData})\cr Data built up by teal} 11 | 12 | \item{dataname}{(\code{character})\cr name of the dataset} 13 | 14 | \item{vars}{(\code{character})\cr Column names in the data} 15 | } 16 | \value{ 17 | \code{character} variable labels. 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 | -------------------------------------------------------------------------------- /man/h_concat_expr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{h_concat_expr} 4 | \alias{h_concat_expr} 5 | \title{Expression Deparsing} 6 | \usage{ 7 | h_concat_expr(expr) 8 | } 9 | \arguments{ 10 | \item{expr}{(\code{call})\cr or an object which can be used as so.} 11 | } 12 | \value{ 13 | a \code{string}. 14 | } 15 | \description{ 16 | Deparse an expression into a \code{string}. 17 | } 18 | \examples{ 19 | expr <- quote({ 20 | library(rtables) 21 | basic_table() \%>\% 22 | split_cols_by(var = "ARMCD") \%>\% 23 | test_proportion_diff( 24 | vars = "rsp", method = "cmh", variables = list(strata = "strata") 25 | ) \%>\% 26 | build_table(df = dta) 27 | }) 28 | 29 | h_concat_expr(expr) 30 | } 31 | -------------------------------------------------------------------------------- /man/is.cs_or_des.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{is.cs_or_des} 4 | \alias{is.cs_or_des} 5 | \title{Whether object is of class \code{\link[teal.transform:choices_selected]{teal.transform::choices_selected()}}} 6 | \usage{ 7 | is.cs_or_des(x) 8 | } 9 | \arguments{ 10 | \item{x}{object to be checked} 11 | } 12 | \value{ 13 | (\code{logical}) 14 | } 15 | \description{ 16 | Whether object is of class \code{\link[teal.transform:choices_selected]{teal.transform::choices_selected()}} 17 | } 18 | -------------------------------------------------------------------------------- /man/make_barchart_simple_call.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_g_barchart_simple.R 3 | \name{make_barchart_simple_call} 4 | \alias{make_barchart_simple_call} 5 | \title{\code{ggplot2} call to generate simple bar chart} 6 | \usage{ 7 | make_barchart_simple_call( 8 | y_name, 9 | x_name = NULL, 10 | fill_name = NULL, 11 | x_facet_name = NULL, 12 | y_facet_name = NULL, 13 | label_bars = TRUE, 14 | barlayout = c("side_by_side", "stacked"), 15 | flip_axis = FALSE, 16 | rotate_bar_labels = FALSE, 17 | rotate_x_label = FALSE, 18 | rotate_y_label = FALSE, 19 | expand_y_range = 0, 20 | facet_scales = "free_x", 21 | ggplot2_args = teal.widgets::ggplot2_args() 22 | ) 23 | } 24 | \arguments{ 25 | \item{y_name}{(\code{character} or \code{NULL})\cr name of the y-axis variable.} 26 | 27 | \item{x_name}{(\code{character} or \code{NULL})\cr name of the x-axis variable. Defaults to \code{NULL} because it is dependent 28 | on extract input which can be empty.} 29 | 30 | \item{fill_name}{(\code{character} or \code{NULL})\cr name of the variable to determine the bar fill color.} 31 | 32 | \item{x_facet_name}{(\code{character} or \code{NULL})\cr name of the variable to use for horizontal plot faceting.} 33 | 34 | \item{y_facet_name}{(\code{character} or \code{NULL})\cr name of the variable to use for vertical plot faceting.} 35 | 36 | \item{label_bars}{(\code{logical} or \code{NULL})\cr whether bars should be labeled. If \code{TRUE}, label bar numbers would 37 | also be drawn as text.} 38 | 39 | \item{barlayout}{(\code{character} or \code{NULL})\cr type of the bar layout. Options are \code{"stacked"} (default) or 40 | \code{"side_by_side"}.} 41 | 42 | \item{flip_axis}{(\code{character} or \code{NULL})\cr whether to flip the plot axis.} 43 | 44 | \item{rotate_bar_labels}{(\code{logical} or \code{NULL})\cr whether bar labels should be rotated by 45 degrees.} 45 | 46 | \item{rotate_x_label}{(\code{logical} or \code{NULL})\cr whether x-axis labels should be rotated by 45 degrees.} 47 | 48 | \item{rotate_y_label}{(\code{logical} or \code{NULL})\cr whether y-axis labels should be rotated by 45 degrees.} 49 | 50 | \item{expand_y_range}{(\code{numeric} or \code{NULL})\cr fraction of y-axis range to further expand by.} 51 | 52 | \item{facet_scales}{(\code{character})\cr value passed to \code{scales} argument of \code{\link[ggplot2:facet_grid]{ggplot2::facet_grid()}}. Options are 53 | \code{fixed}, \code{free_x}, \code{free_y}, and \code{free}.} 54 | 55 | \item{ggplot2_args}{(\code{ggplot2_args}) optional\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings 56 | for the module plot. The argument is merged with option \code{teal.ggplot2_args} and with default module arguments 57 | (hard coded in the module body). 58 | For more details, see the vignette: \code{vignette("custom-ggplot2-arguments", package = "teal.widgets")}.} 59 | } 60 | \value{ 61 | \code{call} to produce a \code{ggplot} object. 62 | } 63 | \description{ 64 | \code{ggplot2} call to generate simple bar chart 65 | } 66 | \keyword{internal} 67 | -------------------------------------------------------------------------------- /man/pipe_expr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{pipe_expr} 4 | \alias{pipe_expr} 5 | \title{Expressions as a Pipeline} 6 | \usage{ 7 | pipe_expr(exprs, pipe_str = "\%>\%") 8 | } 9 | \arguments{ 10 | \item{exprs}{(\code{list} of \code{call})\cr expressions to concatenate in a 11 | pipeline (\verb{\%>\%}).} 12 | 13 | \item{pipe_str}{(\code{character})\cr the character which separates the expressions.} 14 | } 15 | \value{ 16 | a \code{call} 17 | } 18 | \description{ 19 | Concatenate expressions in a single pipeline-flavor expression. 20 | } 21 | \examples{ 22 | pipe_expr( 23 | list( 24 | expr1 = substitute(df), 25 | expr2 = substitute(head) 26 | ) 27 | ) 28 | 29 | } 30 | -------------------------------------------------------------------------------- /man/prepare_arm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{prepare_arm} 4 | \alias{prepare_arm} 5 | \title{Expression: Arm Preparation} 6 | \usage{ 7 | prepare_arm( 8 | dataname, 9 | arm_var, 10 | ref_arm, 11 | comp_arm, 12 | compare_arm = !is.null(ref_arm), 13 | ref_arm_val = paste(ref_arm, collapse = "/"), 14 | drop = TRUE 15 | ) 16 | } 17 | \arguments{ 18 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 19 | 20 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 21 | 22 | \item{ref_arm}{(\code{character})\cr the level of reference arm in case of arm comparison.} 23 | 24 | \item{comp_arm}{(\code{character})\cr the level of comparison arm in case of arm comparison.} 25 | 26 | \item{compare_arm}{(\code{logical})\cr triggers the comparison between study arms.} 27 | 28 | \item{ref_arm_val}{(\code{character})\cr replacement name for the reference level.} 29 | 30 | \item{drop}{(\code{logical})\cr drop the unused variable levels.} 31 | } 32 | \value{ 33 | a \code{call} 34 | } 35 | \description{ 36 | The function generate the standard expression for pre-processing of dataset 37 | in teal module applications. This is especially of interest when the same 38 | preprocessing steps needs to be applied similarly to several datasets 39 | (e.g. \code{ADSL} and \code{ADRS}). 40 | } 41 | \details{ 42 | In \code{teal.modules.clinical}, the user interface includes manipulation of 43 | the study arms. Classically: the arm variable itself (e.g. \code{ARM}, \code{ACTARM}), 44 | the reference arm (0 or more), the comparison arm (1 or more) and the 45 | possibility to combine comparison arms. 46 | 47 | Note that when no arms should be compared with each other, then the produced 48 | expression is reduced to optionally dropping non-represented levels of the arm. 49 | 50 | When comparing arms, the pre-processing includes three steps: 51 | \enumerate{ 52 | \item Filtering of the dataset to retain only the arms of interest (reference 53 | and comparison). 54 | \item Optional, if more than one arm is designated as \emph{reference} they are 55 | combined into a single level. 56 | \item The reference is explicitly reassigned and the non-represented levels of 57 | arm are dropped. 58 | } 59 | } 60 | \examples{ 61 | prepare_arm( 62 | dataname = "adrs", 63 | arm_var = "ARMCD", 64 | ref_arm = "ARM A", 65 | comp_arm = c("ARM B", "ARM C") 66 | ) 67 | 68 | prepare_arm( 69 | dataname = "adsl", 70 | arm_var = "ARMCD", 71 | ref_arm = c("ARM B", "ARM C"), 72 | comp_arm = "ARM A" 73 | ) 74 | 75 | } 76 | -------------------------------------------------------------------------------- /man/prepare_arm_levels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{prepare_arm_levels} 4 | \alias{prepare_arm_levels} 5 | \title{Expression: Prepare Arm Levels} 6 | \usage{ 7 | prepare_arm_levels(dataname, parentname, arm_var, drop_arm_levels = TRUE) 8 | } 9 | \arguments{ 10 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 11 | 12 | \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} 13 | 14 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 15 | 16 | \item{drop_arm_levels}{(\code{logical})\cr whether to drop unused levels of \code{arm_var}. If \code{TRUE}, \code{arm_var} levels are 17 | set to those used in the \code{dataname} dataset. If \code{FALSE}, \code{arm_var} levels are set to those used in the 18 | \code{parentname} dataset. If \code{dataname} and \code{parentname} are the same, then \code{drop_arm_levels} is set to \code{TRUE} and 19 | user input for this parameter is ignored.} 20 | } 21 | \value{ 22 | a \verb{\{} object. See \code{\link[base:Paren]{base::Paren()}} for details. 23 | } 24 | \description{ 25 | This function generates the standard expression for pre-processing of dataset 26 | arm levels in and is used to apply the same steps in safety teal modules. 27 | } 28 | \examples{ 29 | prepare_arm_levels( 30 | dataname = "adae", 31 | parentname = "adsl", 32 | arm_var = "ARMCD", 33 | drop_arm_levels = TRUE 34 | ) 35 | 36 | prepare_arm_levels( 37 | dataname = "adae", 38 | parentname = "adsl", 39 | arm_var = "ARMCD", 40 | drop_arm_levels = FALSE 41 | ) 42 | 43 | } 44 | -------------------------------------------------------------------------------- /man/select_decorators.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{select_decorators} 4 | \alias{select_decorators} 5 | \title{Subset decorators based on the scope} 6 | \usage{ 7 | select_decorators(decorators, scope) 8 | } 9 | \arguments{ 10 | \item{decorators}{(named \code{list}) of list decorators to subset.} 11 | 12 | \item{scope}{(\code{character}) a character vector of decorator names to include.} 13 | } 14 | \value{ 15 | Subsetted list with all decorators to include. 16 | It can be an empty list if none of the scope exists in \code{decorators} argument. 17 | } 18 | \description{ 19 | Subset decorators based on the scope 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/split_choices.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{split_choices} 4 | \alias{split_choices} 5 | \title{Split \code{choices_selected} objects with interactions into 6 | their component variables} 7 | \usage{ 8 | split_choices(x) 9 | } 10 | \arguments{ 11 | \item{x}{(\code{choices_selected})\cr 12 | object with interaction terms} 13 | } 14 | \value{ 15 | a \code{\link[teal.transform:choices_selected]{teal.transform::choices_selected()}} object. 16 | } 17 | \description{ 18 | Split \code{choices_selected} objects with interactions into 19 | their component variables 20 | } 21 | \note{ 22 | uses the regex \verb{\\\\*|:} to perform the split. 23 | } 24 | \examples{ 25 | split_choices(choices_selected(choices = c("x:y", "a*b"), selected = all_choices())) 26 | 27 | } 28 | -------------------------------------------------------------------------------- /man/split_col_expr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{split_col_expr} 4 | \alias{split_col_expr} 5 | \title{Split-Column Expression} 6 | \usage{ 7 | split_col_expr(compare, combine, ref, arm_var) 8 | } 9 | \arguments{ 10 | \item{compare}{(\code{logical})\cr if \code{TRUE} the reference level is included.} 11 | 12 | \item{combine}{(\code{logical})\cr if \code{TRUE} the group combination is included.} 13 | 14 | \item{ref}{(\code{character})\cr the reference level (not used for \code{combine = TRUE}).} 15 | 16 | \item{arm_var}{(\code{character})\cr the arm or grouping variable name.} 17 | } 18 | \value{ 19 | a \code{call} 20 | } 21 | \description{ 22 | Renders the expression for column split in \code{rtables} depending on: 23 | \itemize{ 24 | \item the expected or not arm comparison 25 | \item the expected or not arm combination 26 | } 27 | } 28 | \examples{ 29 | split_col_expr( 30 | compare = TRUE, 31 | combine = FALSE, 32 | ref = "ARM A", 33 | arm_var = "ARMCD" 34 | ) 35 | 36 | } 37 | -------------------------------------------------------------------------------- /man/split_interactions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{split_interactions} 4 | \alias{split_interactions} 5 | \title{Split interaction terms into their component variables} 6 | \usage{ 7 | split_interactions(x, by = "\\\\*|:") 8 | } 9 | \arguments{ 10 | \item{x}{(\code{character})\cr 11 | string representing the interaction 12 | usually in the form \code{x:y} or \code{x*y}.} 13 | 14 | \item{by}{(\code{character})\cr 15 | regex with which to split the interaction 16 | term by.} 17 | } 18 | \value{ 19 | a vector of strings where each element is a component 20 | variable extracted from interaction term \code{x}. 21 | } 22 | \description{ 23 | Split interaction terms into their component variables 24 | } 25 | \examples{ 26 | split_interactions("x:y") 27 | split_interactions("x*y") 28 | 29 | } 30 | -------------------------------------------------------------------------------- /man/srv_decorate_teal_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{srv_decorate_teal_data} 4 | \alias{srv_decorate_teal_data} 5 | \alias{ui_decorate_teal_data} 6 | \title{Wrappers around \code{srv_transform_teal_data} that allows to decorate the data} 7 | \usage{ 8 | srv_decorate_teal_data(id, data, decorators, expr, expr_is_reactive = FALSE) 9 | 10 | ui_decorate_teal_data(id, decorators, ...) 11 | } 12 | \arguments{ 13 | \item{id}{(\code{character(1)}) \code{shiny} module instance id.} 14 | 15 | \item{data}{(\code{reactive} returning \code{teal_data})} 16 | 17 | \item{expr}{(\code{expression} or \code{reactive}) to evaluate on the output of the decoration. 18 | When an expression it must be inline code. See \code{\link[=within]{within()}} 19 | Default is \code{NULL} which won't evaluate any appending code.} 20 | 21 | \item{expr_is_reactive}{(\code{logical(1)}) whether \code{expr} is a reactive expression 22 | that skips defusing the argument.} 23 | } 24 | \description{ 25 | Wrappers around \code{srv_transform_teal_data} that allows to decorate the data 26 | } 27 | \details{ 28 | \code{srv_decorate_teal_data} is a wrapper around \code{srv_transform_teal_data} that 29 | allows to decorate the data with additional expressions. 30 | When original \code{teal_data} object is in error state, it will show that error 31 | first. 32 | 33 | \code{ui_decorate_teal_data} is a wrapper around \code{ui_transform_teal_data}. 34 | } 35 | \keyword{internal} 36 | -------------------------------------------------------------------------------- /man/substitute_names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/substitute_names.R 3 | \name{substitute_names} 4 | \alias{substitute_names} 5 | \alias{h_subst_lhs_names} 6 | \alias{substitute_lhs_names} 7 | \alias{substitute_rhs} 8 | \title{Substitute Names in a Quoted Expression} 9 | \usage{ 10 | substitute_names(expr, names, others = list()) 11 | 12 | h_subst_lhs_names(qexpr, names) 13 | 14 | substitute_lhs_names(qexpr, names) 15 | 16 | substitute_rhs(qexpr, env) 17 | } 18 | \arguments{ 19 | \item{expr}{(\code{language})\cr an expression.} 20 | 21 | \item{names}{(named \code{list} of \code{name})\cr requested name substitutions.} 22 | 23 | \item{others}{(named \code{list})\cr requested other substitutions which will only happen on the 24 | right-hand side.} 25 | 26 | \item{qexpr}{(\code{language})\cr a quoted expression.} 27 | 28 | \item{env}{(\code{environment} or \code{list})\cr requested variable substitutions.} 29 | } 30 | \value{ 31 | The modified expression. 32 | } 33 | \description{ 34 | This function substitutes the names on both left- and right-hand sides in a quoted expression. 35 | In addition it can also do other standard substitutions on the right-hand side. 36 | } 37 | \section{Functions}{ 38 | \itemize{ 39 | \item \code{h_subst_lhs_names()}: Helper function to just substitute the top-level names on the left-hand side in a 40 | quoted expression. 41 | 42 | \item \code{substitute_lhs_names()}: recursively substitutes all names on the left-hand sides in a quoted expression. 43 | 44 | \item \code{substitute_rhs()}: substitutes on the right-hand side in a quoted expression. 45 | Note that this is just a synonym for \code{\link[=substitute_q]{substitute_q()}}. 46 | 47 | }} 48 | \seealso{ 49 | \code{\link[=substitute_q]{substitute_q()}} 50 | } 51 | \keyword{internal} 52 | -------------------------------------------------------------------------------- /man/substitute_q.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/substitute_names.R 3 | \name{substitute_q} 4 | \alias{substitute_q} 5 | \title{Substitute in Quoted Expressions} 6 | \usage{ 7 | substitute_q(qexpr, env) 8 | } 9 | \arguments{ 10 | \item{qexpr}{(\code{language})\cr a quoted expression.} 11 | 12 | \item{env}{(\code{environment} or \code{list})\cr requested variable substitutions.} 13 | } 14 | \value{ 15 | The modified expression. 16 | } 17 | \description{ 18 | This version of substitute is needed because \code{\link[=substitute]{substitute()}} does not 19 | evaluate it's first argument, and it's often useful to be able to modify 20 | a quoted expression. 21 | } 22 | \note{ 23 | This is simplified from the package \code{pryr} to avoid another dependency. 24 | } 25 | \seealso{ 26 | \code{\link[=substitute_names]{substitute_names()}} 27 | } 28 | \keyword{internal} 29 | -------------------------------------------------------------------------------- /man/teal.modules.clinical-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/teal.modules.clinical.R 3 | \docType{package} 4 | \name{teal.modules.clinical-package} 5 | \alias{teal.modules.clinical} 6 | \alias{teal.modules.clinical-package} 7 | \title{\code{teal} Modules for Standard Clinical Outputs} 8 | \description{ 9 | Provides teal modules for the standard clinical trials outputs. 10 | The teal modules add an encoding panel to interactively change the encodings within teal. 11 | } 12 | \seealso{ 13 | Useful links: 14 | \itemize{ 15 | \item \url{https://insightsengineering.github.io/teal.modules.clinical/} 16 | \item \url{https://github.com/insightsengineering/teal.modules.clinical/} 17 | \item Report bugs at \url{https://github.com/insightsengineering/teal.modules.clinical/issues} 18 | } 19 | 20 | } 21 | \author{ 22 | \strong{Maintainer}: Dawid Kaledkowski \email{dawid.kaledkowski@roche.com} 23 | 24 | Authors: 25 | \itemize{ 26 | \item Joe Zhu \email{joe.zhu@roche.com} (\href{https://orcid.org/0000-0001-7566-2787}{ORCID}) 27 | \item Jana Stoilova \email{jana.stoilova@roche.com} 28 | \item Davide Garolini \email{davide.garolini@roche.com} 29 | \item Emily de la Rua \email{emily.de_la_rua@contractors.roche.com} 30 | \item Abinaya Yogasekaram \email{abinaya.yogasekaram@contractors.roche.com} 31 | \item Mahmoud Hallal \email{mahmoud.hallal@roche.com} 32 | \item Rosemary Li \email{li.yaqiong@gene.com} 33 | \item Heng Wang \email{wang.heng@gene.com} 34 | \item Pawel Rucki \email{pawel.rucki@roche.com} 35 | \item Nikolas Burkoff 36 | \item Konrad Pagacz 37 | } 38 | 39 | Other contributors: 40 | \itemize{ 41 | \item Vaakesan Sundrelingam [contributor] 42 | \item Francois Collin [contributor] 43 | \item Imanol Zubizarreta [contributor] 44 | \item F. Hoffmann-La Roche AG [copyright holder, funder] 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /man/template_a_gee.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_a_gee.R 3 | \name{template_a_gee} 4 | \alias{template_a_gee} 5 | \title{Template for Generalized Estimating Equations (GEE) analysis module} 6 | \usage{ 7 | template_a_gee( 8 | output_table, 9 | data_model_fit = "ANL", 10 | dataname_lsmeans = "ANL_ADSL", 11 | input_arm_var = "ARM", 12 | ref_group = "A: Drug X", 13 | aval_var, 14 | id_var, 15 | arm_var, 16 | visit_var, 17 | split_covariates, 18 | cor_struct, 19 | conf_level = 0.95, 20 | basic_table_args = teal.widgets::basic_table_args() 21 | ) 22 | } 23 | \arguments{ 24 | \item{output_table}{(\code{character})\cr type of output table (\verb{"t_gee_cov", "t_gee_coef", "t_gee_lsmeans"}).} 25 | 26 | \item{data_model_fit}{(\code{character})\cr dataset used to fit the model by \code{tern.gee::fit_gee()}.} 27 | 28 | \item{dataname_lsmeans}{(\code{character})\cr dataset used for \code{alt_counts_df} argument of \code{rtables::build_table()}.} 29 | 30 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 31 | 32 | \item{id_var}{(\code{character})\cr the variable name for subject id.} 33 | 34 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 35 | 36 | \item{visit_var}{(\code{character})\cr variable names that can be used as \code{visit} variable. Must be a factor in 37 | \code{dataname}.} 38 | 39 | \item{split_covariates}{(\code{character})\cr vector of names of variables to use as covariates in 40 | \code{tern.gee::vars_gee()}.} 41 | 42 | \item{cor_struct}{(\code{character})\cr assumed correlation structure in \code{tern.gee::fit_gee}.} 43 | 44 | \item{conf_level}{(\code{numeric})\cr value for the confidence level within the range of (0, 1).} 45 | 46 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 47 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 48 | module arguments (hard coded in the module body). 49 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 50 | } 51 | \value{ 52 | a \code{list} of expressions to generate a table or plot object. 53 | } 54 | \description{ 55 | Creates a valid expression to generate an analysis table using Generalized Estimating Equations (GEE). 56 | } 57 | \seealso{ 58 | \code{\link[=tm_a_gee]{tm_a_gee()}} 59 | } 60 | \keyword{internal} 61 | -------------------------------------------------------------------------------- /man/template_abnormality_by_worst_grade.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_abnormality_by_worst_grade.R 3 | \name{template_abnormality_by_worst_grade} 4 | \alias{template_abnormality_by_worst_grade} 5 | \title{Template: Laboratory test results with highest grade post-baseline} 6 | \usage{ 7 | template_abnormality_by_worst_grade( 8 | parentname, 9 | dataname, 10 | arm_var, 11 | id_var = "USUBJID", 12 | paramcd = "PARAMCD", 13 | atoxgr_var = "ATOXGR", 14 | worst_high_flag_var = "WGRHIFL", 15 | worst_low_flag_var = "WGRLOFL", 16 | worst_flag_indicator = "Y", 17 | add_total = FALSE, 18 | total_label = default_total_label(), 19 | drop_arm_levels = TRUE, 20 | basic_table_args = teal.widgets::basic_table_args() 21 | ) 22 | } 23 | \arguments{ 24 | \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} 25 | 26 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 27 | 28 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 29 | 30 | \item{id_var}{(\code{character})\cr the variable name for subject id.} 31 | 32 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 33 | 34 | \item{atoxgr_var}{(\code{character})\cr name of the variable indicating 35 | Analysis Toxicity Grade.} 36 | 37 | \item{worst_high_flag_var}{(\code{character})\cr name of the variable indicating 38 | Worst High Grade flag} 39 | 40 | \item{worst_low_flag_var}{(\code{character})\cr name of the variable indicating 41 | Worst Low Grade flag} 42 | 43 | \item{worst_flag_indicator}{(\code{character})\cr flag value indicating the worst grade.} 44 | 45 | \item{add_total}{(\code{logical})\cr whether to include column with total number of patients.} 46 | 47 | \item{total_label}{(\code{string})\cr string to display as total column/row label if column/row is 48 | enabled (see \code{add_total}). Defaults to \code{"All Patients"}. To set a new default \code{total_label} to 49 | apply in all modules, run \code{set_default_total_label("new_default")}.} 50 | 51 | \item{drop_arm_levels}{(\code{logical})\cr whether to drop unused levels of \code{arm_var}. If \code{TRUE}, \code{arm_var} levels are 52 | set to those used in the \code{dataname} dataset. If \code{FALSE}, \code{arm_var} levels are set to those used in the 53 | \code{parentname} dataset. If \code{dataname} and \code{parentname} are the same, then \code{drop_arm_levels} is set to \code{TRUE} and 54 | user input for this parameter is ignored.} 55 | 56 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 57 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 58 | module arguments (hard coded in the module body). 59 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 60 | } 61 | \value{ 62 | a \code{list} of expressions to generate a table or plot object. 63 | } 64 | \description{ 65 | Creates a valid expression to generate a table to summarize abnormality by grade. 66 | } 67 | \seealso{ 68 | \code{\link[=tm_t_abnormality_by_worst_grade]{tm_t_abnormality_by_worst_grade()}} 69 | } 70 | \keyword{internal} 71 | -------------------------------------------------------------------------------- /man/template_adverse_events.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_g_pp_adverse_events.R 3 | \name{template_adverse_events} 4 | \alias{template_adverse_events} 5 | \title{Template: Patient Profile Adverse Events Table and Plot} 6 | \usage{ 7 | template_adverse_events( 8 | dataname = "ANL", 9 | aeterm = "AETERM", 10 | tox_grade = "AETOXGR", 11 | causality = "AEREL", 12 | outcome = "AEOUT", 13 | action = "AEACN", 14 | time = "ASTDY", 15 | decod = NULL, 16 | patient_id, 17 | font_size = 12L, 18 | ggplot2_args = teal.widgets::ggplot2_args() 19 | ) 20 | } 21 | \arguments{ 22 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 23 | 24 | \item{aeterm}{(\code{character})\cr name of the reported term for the adverse event variable.} 25 | 26 | \item{tox_grade}{(\code{character})\cr name of the standard toxicity grade variable.} 27 | 28 | \item{causality}{(\code{character})\cr name of the causality variable.} 29 | 30 | \item{outcome}{(\code{character})\cr name of outcome of adverse event variable.} 31 | 32 | \item{action}{(\code{character})\cr name of action taken with study treatment variable.} 33 | 34 | \item{time}{(\code{character})\cr name of study day of start of adverse event variable.} 35 | 36 | \item{decod}{(\code{character})\cr name of dictionary derived term variable.} 37 | 38 | \item{patient_id}{(\code{character})\cr patient ID.} 39 | 40 | \item{font_size}{(\code{numeric})\cr font size value.} 41 | 42 | \item{ggplot2_args}{(\code{ggplot2_args}) optional\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings 43 | for the module plot. The argument is merged with option \code{teal.ggplot2_args} and with default module arguments 44 | (hard coded in the module body). 45 | For more details, see the vignette: \code{vignette("custom-ggplot2-arguments", package = "teal.widgets")}.} 46 | } 47 | \value{ 48 | a \code{list} of expressions to generate a table or plot object. 49 | } 50 | \description{ 51 | Creates a valid expression to generate an adverse events table and \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} plot using ADaM datasets. 52 | } 53 | \seealso{ 54 | \code{\link[=tm_g_pp_adverse_events]{tm_g_pp_adverse_events()}} 55 | } 56 | \keyword{internal} 57 | -------------------------------------------------------------------------------- /man/template_ancova.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_ancova.R 3 | \name{template_ancova} 4 | \alias{template_ancova} 5 | \title{Template: ANCOVA Summary} 6 | \usage{ 7 | template_ancova( 8 | dataname = "ANL", 9 | parentname = "ADSL", 10 | arm_var, 11 | ref_arm = NULL, 12 | comp_arm = NULL, 13 | combine_comp_arms = FALSE, 14 | aval_var, 15 | label_aval = NULL, 16 | cov_var, 17 | include_interact = FALSE, 18 | interact_var = NULL, 19 | interact_y = FALSE, 20 | paramcd_levels = "", 21 | paramcd_var = "PARAMCD", 22 | label_paramcd = NULL, 23 | visit_levels = "", 24 | visit_var = "AVISIT", 25 | conf_level = 0.95, 26 | basic_table_args = teal.widgets::basic_table_args() 27 | ) 28 | } 29 | \arguments{ 30 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 31 | 32 | \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} 33 | 34 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 35 | 36 | \item{ref_arm}{(\code{character})\cr the level of reference arm in case of arm comparison.} 37 | 38 | \item{comp_arm}{(\code{character})\cr the level of comparison arm in case of arm comparison.} 39 | 40 | \item{combine_comp_arms}{(\code{logical})\cr triggers the combination of comparison arms.} 41 | 42 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 43 | 44 | \item{label_aval}{(\code{character})\cr 45 | label of value variable used for title rendering.} 46 | 47 | \item{cov_var}{(\code{character})\cr names of the covariates variables.} 48 | 49 | \item{include_interact}{(\code{logical})\cr whether an interaction term should be included in the model.} 50 | 51 | \item{interact_var}{(\code{character})\cr name of the variable that should have interactions with arm. If the 52 | interaction is not needed, the default option is \code{NULL}.} 53 | 54 | \item{interact_y}{(\code{character})\cr a selected item from the \code{interact_var} column which will be used to select the 55 | specific ANCOVA results. If the interaction is not needed, the default option is \code{FALSE}.} 56 | 57 | \item{paramcd_levels}{(\code{character})\cr 58 | variable levels for the studied parameter.} 59 | 60 | \item{paramcd_var}{(\code{character})\cr 61 | variable name for the studied parameter.} 62 | 63 | \item{label_paramcd}{(\code{character})\cr 64 | variable label used for title rendering.} 65 | 66 | \item{visit_levels}{(\code{character})\cr 67 | variable levels for studied visits.} 68 | 69 | \item{visit_var}{(\code{character})\cr variable names that can be used as \code{visit} variable. Must be a factor in 70 | \code{dataname}.} 71 | 72 | \item{conf_level}{(\code{numeric})\cr value for the confidence level within the range of (0, 1).} 73 | 74 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 75 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 76 | module arguments (hard coded in the module body). 77 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 78 | } 79 | \value{ 80 | a \code{list} of expressions to generate a table or plot object. 81 | } 82 | \description{ 83 | Creates a valid expression to generate an analysis of variance summary table. 84 | } 85 | \seealso{ 86 | \code{\link[=tm_t_ancova]{tm_t_ancova()}} 87 | } 88 | \keyword{internal} 89 | -------------------------------------------------------------------------------- /man/template_basic_info.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_pp_basic_info.R 3 | \name{template_basic_info} 4 | \alias{template_basic_info} 5 | \title{Template: Patient Profile Basic Info} 6 | \usage{ 7 | template_basic_info(dataname = "ANL", vars, patient_id = NULL) 8 | } 9 | \arguments{ 10 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 11 | 12 | \item{vars}{(\code{character})\cr names of the variables to be shown in the table.} 13 | 14 | \item{patient_id}{(\code{character})\cr patient ID.} 15 | } 16 | \value{ 17 | a \code{list} of expressions to generate a table or plot object. 18 | } 19 | \description{ 20 | Creates a valid expression to generate a patient profile basic info report using ADaM datasets. 21 | } 22 | \seealso{ 23 | \code{\link[=tm_t_pp_basic_info]{tm_t_pp_basic_info()}} 24 | } 25 | \keyword{internal} 26 | -------------------------------------------------------------------------------- /man/template_coxreg_m.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_coxreg.R 3 | \name{template_coxreg_m} 4 | \alias{template_coxreg_m} 5 | \title{Template: Multi-Variable Cox Regression} 6 | \usage{ 7 | template_coxreg_m( 8 | dataname, 9 | cov_var, 10 | arm_var, 11 | cnsr_var, 12 | aval_var, 13 | ref_arm, 14 | comp_arm, 15 | paramcd, 16 | at = list(), 17 | strata_var = NULL, 18 | combine_comp_arms = FALSE, 19 | control = control_coxreg(), 20 | na_level = default_na_str(), 21 | basic_table_args = teal.widgets::basic_table_args() 22 | ) 23 | } 24 | \arguments{ 25 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 26 | 27 | \item{cov_var}{(\code{character})\cr names of the covariates variables.} 28 | 29 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 30 | 31 | \item{cnsr_var}{(\code{character})\cr name of the censoring variable.} 32 | 33 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 34 | 35 | \item{ref_arm}{(\code{character})\cr the level of reference arm in case of arm comparison.} 36 | 37 | \item{comp_arm}{(\code{character})\cr the level of comparison arm in case of arm comparison.} 38 | 39 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 40 | 41 | \item{at}{(\code{list} of \code{numeric})\cr when the candidate covariate is a \code{numeric} type variable, use \code{at} 42 | to specify the value of the covariate at which the effect should be estimated.} 43 | 44 | \item{strata_var}{(\code{character})\cr names of the variables for stratified analysis.} 45 | 46 | \item{combine_comp_arms}{(\code{logical})\cr triggers the combination of comparison arms.} 47 | 48 | \item{control}{(\code{list})\cr list of settings for the analysis (see \code{\link[tern:control_coxreg]{tern::control_coxreg()}}).} 49 | 50 | \item{na_level}{(\code{string})\cr used to replace all \code{NA} or empty values 51 | in character or factor variables in the data. Defaults to \code{"<Missing>"}. To set a 52 | default \code{na_level} to apply in all modules, run \code{set_default_na_str("new_default")}.} 53 | 54 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 55 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 56 | module arguments (hard coded in the module body). 57 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 58 | } 59 | \value{ 60 | a \code{list} of expressions to generate a table or plot object. 61 | } 62 | \description{ 63 | Creates a valid expression to generate a multi-variable Cox regression analysis. 64 | } 65 | \seealso{ 66 | \code{\link[=template_coxreg_u]{template_coxreg_u()}}, \code{\link[=tm_t_coxreg]{tm_t_coxreg()}} 67 | } 68 | \keyword{internal} 69 | -------------------------------------------------------------------------------- /man/template_coxreg_u.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_coxreg.R 3 | \name{template_coxreg_u} 4 | \alias{template_coxreg_u} 5 | \title{Template: Univariable Cox Regression} 6 | \usage{ 7 | template_coxreg_u( 8 | dataname, 9 | cov_var, 10 | arm_var, 11 | cnsr_var, 12 | aval_var, 13 | ref_arm, 14 | comp_arm, 15 | paramcd, 16 | at = list(), 17 | strata_var = NULL, 18 | combine_comp_arms = FALSE, 19 | control = control_coxreg(), 20 | na_level = default_na_str(), 21 | append = FALSE, 22 | basic_table_args = teal.widgets::basic_table_args() 23 | ) 24 | } 25 | \arguments{ 26 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 27 | 28 | \item{cov_var}{(\code{character})\cr names of the covariates variables.} 29 | 30 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 31 | 32 | \item{cnsr_var}{(\code{character})\cr name of the censoring variable.} 33 | 34 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 35 | 36 | \item{ref_arm}{(\code{character})\cr the level of reference arm in case of arm comparison.} 37 | 38 | \item{comp_arm}{(\code{character})\cr the level of comparison arm in case of arm comparison.} 39 | 40 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 41 | 42 | \item{at}{(\code{list} of \code{numeric})\cr when the candidate covariate is a \code{numeric} type variable, use \code{at} 43 | to specify the value of the covariate at which the effect should be estimated.} 44 | 45 | \item{strata_var}{(\code{character})\cr names of the variables for stratified analysis.} 46 | 47 | \item{combine_comp_arms}{(\code{logical})\cr triggers the combination of comparison arms.} 48 | 49 | \item{control}{(\code{list})\cr list of settings for the analysis (see \code{\link[tern:control_coxreg]{tern::control_coxreg()}}).} 50 | 51 | \item{na_level}{(\code{string})\cr used to replace all \code{NA} or empty values 52 | in character or factor variables in the data. Defaults to \code{"<Missing>"}. To set a 53 | default \code{na_level} to apply in all modules, run \code{set_default_na_str("new_default")}.} 54 | 55 | \item{append}{(\code{logical})\cr whether the result should be appended to the previous one.} 56 | 57 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 58 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 59 | module arguments (hard coded in the module body). 60 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 61 | } 62 | \value{ 63 | a \code{list} of expressions to generate a table or plot object. 64 | } 65 | \description{ 66 | Creates a valid expression to generate a univariable Cox regression analysis. 67 | } 68 | \seealso{ 69 | \code{\link[=template_coxreg_m]{template_coxreg_m()}}, \code{\link[=tm_t_coxreg]{tm_t_coxreg()}} 70 | } 71 | \keyword{internal} 72 | -------------------------------------------------------------------------------- /man/template_events_patyear.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_events_patyear.R 3 | \name{template_events_patyear} 4 | \alias{template_events_patyear} 5 | \title{Template: Event Rates Adjusted for Patient-Years} 6 | \usage{ 7 | template_events_patyear( 8 | dataname, 9 | parentname, 10 | arm_var, 11 | events_var, 12 | label_paramcd, 13 | aval_var = "AVAL", 14 | add_total = TRUE, 15 | total_label = default_total_label(), 16 | na_level = default_na_str(), 17 | control = control_incidence_rate(), 18 | drop_arm_levels = TRUE, 19 | basic_table_args = teal.widgets::basic_table_args() 20 | ) 21 | } 22 | \arguments{ 23 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 24 | 25 | \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} 26 | 27 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 28 | 29 | \item{events_var}{(\code{character})\cr name of the variable for number of observed events.} 30 | 31 | \item{label_paramcd}{(\code{character})\cr \code{paramcd} variable text to use in the table title.} 32 | 33 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 34 | 35 | \item{add_total}{(\code{logical})\cr whether to include column with total number of patients.} 36 | 37 | \item{total_label}{(\code{string})\cr string to display as total column/row label if column/row is 38 | enabled (see \code{add_total}). Defaults to \code{"All Patients"}. To set a new default \code{total_label} to 39 | apply in all modules, run \code{set_default_total_label("new_default")}.} 40 | 41 | \item{na_level}{(\code{string})\cr used to replace all \code{NA} or empty values 42 | in character or factor variables in the data. Defaults to \code{"<Missing>"}. To set a 43 | default \code{na_level} to apply in all modules, run \code{set_default_na_str("new_default")}.} 44 | 45 | \item{control}{(\code{list})\cr list of settings for the analysis.} 46 | 47 | \item{drop_arm_levels}{(\code{logical})\cr whether to drop unused levels of \code{arm_var}. If \code{TRUE}, \code{arm_var} levels are 48 | set to those used in the \code{dataname} dataset. If \code{FALSE}, \code{arm_var} levels are set to those used in the 49 | \code{parentname} dataset. If \code{dataname} and \code{parentname} are the same, then \code{drop_arm_levels} is set to \code{TRUE} and 50 | user input for this parameter is ignored.} 51 | 52 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 53 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 54 | module arguments (hard coded in the module body). 55 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 56 | } 57 | \value{ 58 | a \code{list} of expressions to generate a table or plot object. 59 | } 60 | \description{ 61 | Creates a valid expression to generate a table of event rates adjusted for patient-years. 62 | } 63 | \seealso{ 64 | \code{\link[=tm_t_events_patyear]{tm_t_events_patyear()}} 65 | } 66 | \keyword{internal} 67 | -------------------------------------------------------------------------------- /man/template_exposure.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_exposure.R 3 | \name{template_exposure} 4 | \alias{template_exposure} 5 | \title{Template: Exposure Table for Risk management plan} 6 | \usage{ 7 | template_exposure( 8 | parentname, 9 | dataname, 10 | id_var, 11 | paramcd, 12 | paramcd_label = NULL, 13 | row_by_var, 14 | col_by_var = NULL, 15 | add_total = FALSE, 16 | total_label = "Total", 17 | add_total_row = TRUE, 18 | total_row_label = "Total number of patients and patient time*", 19 | drop_levels = TRUE, 20 | na_level = default_na_str(), 21 | aval_var, 22 | avalu_var, 23 | basic_table_args = teal.widgets::basic_table_args() 24 | ) 25 | } 26 | \arguments{ 27 | \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} 28 | 29 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 30 | 31 | \item{id_var}{(\code{character})\cr the variable name for subject id.} 32 | 33 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 34 | 35 | \item{paramcd_label}{(\code{character})\cr the column from the \code{dataname} dataset where the 36 | value will be used to label the argument \code{paramcd}.} 37 | 38 | \item{row_by_var}{(\code{character})\cr variable name used to split the values by rows.} 39 | 40 | \item{col_by_var}{(\code{character})\cr variable name used to split the values by columns.} 41 | 42 | \item{add_total}{(\code{logical})\cr whether to include column with total number of patients.} 43 | 44 | \item{total_label}{(\code{string})\cr string to display as total column/row label if column/row is 45 | enabled (see \code{add_total}). Defaults to \code{"All Patients"}. To set a new default \code{total_label} to 46 | apply in all modules, run \code{set_default_total_label("new_default")}.} 47 | 48 | \item{add_total_row}{(\code{flag})\cr whether a "total" level should be added after the others which includes all the 49 | levels that constitute the split. A custom label can be set for this level via the \code{total_row_label} argument.} 50 | 51 | \item{total_row_label}{(\code{character})\cr string to display as total row label if row is 52 | enabled (see \code{add_total_row}).} 53 | 54 | \item{drop_levels}{(\code{flag})\cr whether empty rows should be removed from the table.} 55 | 56 | \item{na_level}{(\code{string})\cr used to replace all \code{NA} or empty values 57 | in character or factor variables in the data. Defaults to \code{"<Missing>"}. To set a 58 | default \code{na_level} to apply in all modules, run \code{set_default_na_str("new_default")}.} 59 | 60 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 61 | 62 | \item{avalu_var}{(\code{character})\cr name of the analysis value unit variable.} 63 | 64 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 65 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 66 | module arguments (hard coded in the module body). 67 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 68 | } 69 | \value{ 70 | a \code{list} of expressions to generate a table or plot object. 71 | } 72 | \description{ 73 | Creates a valid expression to generate exposure table for risk management plan. 74 | } 75 | \seealso{ 76 | \code{\link[=tm_t_exposure]{tm_t_exposure()}} 77 | } 78 | \keyword{internal} 79 | -------------------------------------------------------------------------------- /man/template_g_ci.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_g_ci.R 3 | \name{template_g_ci} 4 | \alias{template_g_ci} 5 | \title{Template: Confidence Interval Plot} 6 | \usage{ 7 | template_g_ci( 8 | dataname, 9 | x_var, 10 | y_var, 11 | grp_var = NULL, 12 | stat = c("mean", "median"), 13 | conf_level = 0.95, 14 | unit_var = "AVALU", 15 | ggplot2_args = teal.widgets::ggplot2_args() 16 | ) 17 | } 18 | \arguments{ 19 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 20 | 21 | \item{x_var}{(\code{character})\cr name of the treatment variable to put on the x-axis.} 22 | 23 | \item{y_var}{(\code{character})\cr name of the response variable to put on the y-axis.} 24 | 25 | \item{grp_var}{(\code{character})\cr name of the group variable used to determine the plot colors, point shapes, 26 | and line types.} 27 | 28 | \item{stat}{(\code{character})\cr statistic to plot. Options are \code{"mean"} and \code{"median"}.} 29 | 30 | \item{conf_level}{(\code{numeric})\cr value for the confidence level within the range of (0, 1).} 31 | 32 | \item{unit_var}{(\code{character})\cr name of the unit variable.} 33 | 34 | \item{ggplot2_args}{(\code{ggplot2_args}) optional\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings 35 | for the module plot. The argument is merged with option \code{teal.ggplot2_args} and with default module arguments 36 | (hard coded in the module body). 37 | For more details, see the vignette: \code{vignette("custom-ggplot2-arguments", package = "teal.widgets")}.} 38 | } 39 | \value{ 40 | a \code{list} of expressions to generate a table or plot object. 41 | } 42 | \description{ 43 | Creates a valid expression to generate a \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} confidence interval plot. 44 | } 45 | \seealso{ 46 | \code{\link[=tm_g_ci]{tm_g_ci()}} 47 | } 48 | \keyword{internal} 49 | -------------------------------------------------------------------------------- /man/template_g_ipp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_g_ipp.R 3 | \name{template_g_ipp} 4 | \alias{template_g_ipp} 5 | \title{Template: Individual Patient Plots} 6 | \usage{ 7 | template_g_ipp( 8 | dataname = "ANL", 9 | paramcd, 10 | arm_var, 11 | arm_levels, 12 | avalu_first, 13 | paramcd_first, 14 | aval_var = "AVAL", 15 | avalu_var = "AVALU", 16 | id_var = "USUBJID", 17 | visit_var = "AVISIT", 18 | base_var = lifecycle::deprecated(), 19 | baseline_var = "BASE", 20 | add_baseline_hline = FALSE, 21 | separate_by_obs = FALSE, 22 | ggplot2_args = teal.widgets::ggplot2_args(), 23 | suppress_legend = FALSE, 24 | add_avalu = TRUE 25 | ) 26 | } 27 | \arguments{ 28 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 29 | 30 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 31 | 32 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 33 | 34 | \item{arm_levels}{(\code{character})\cr vector of all levels of \code{arm_var}.} 35 | 36 | \item{avalu_first}{(\code{character})\cr \code{avalu_var} text to append to the plot title and y-axis label if \code{add_avalu} is 37 | \code{TRUE}.} 38 | 39 | \item{paramcd_first}{(\code{character})\cr \code{paramcd} text to append to the plot title and y-axis label.} 40 | 41 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 42 | 43 | \item{avalu_var}{(\code{character})\cr name of the analysis value unit variable.} 44 | 45 | \item{id_var}{(\code{character})\cr the variable name for subject id.} 46 | 47 | \item{visit_var}{(\code{character})\cr name of the variable for visit timepoints.} 48 | 49 | \item{base_var}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{baseline_var} argument instead.} 50 | 51 | \item{baseline_var}{(\code{character})\cr name of the variable for baseline values of the analysis variable.} 52 | 53 | \item{add_baseline_hline}{(\code{logical})\cr whether a horizontal line should be added to the plot at baseline y-value.} 54 | 55 | \item{separate_by_obs}{(\code{logical})\cr whether to create multi-panel plots.} 56 | 57 | \item{ggplot2_args}{(\code{ggplot2_args}) optional\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings 58 | for the module plot. For this module, this argument will only accept \code{ggplot2_args} object with \code{labs} list of 59 | the following child elements: \code{title}, \code{subtitle}, \code{x}, \code{y}. No other elements are taken into account. The 60 | argument is merged with option \code{teal.ggplot2_args} and with default module arguments (hard coded in the module 61 | body). 62 | 63 | For more details, see the vignette: \code{vignette("custom-ggplot2-arguments", package = "teal.widgets")}.} 64 | 65 | \item{suppress_legend}{(\code{logical})\cr whether to suppress the plot legend.} 66 | 67 | \item{add_avalu}{(\code{logical})\cr whether \code{avalu_first} text should be appended to the plot title and y-axis label.} 68 | } 69 | \value{ 70 | a \code{list} of expressions to generate a table or plot object. 71 | } 72 | \description{ 73 | Creates a valid expression to generate \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} plots of individual patients. 74 | } 75 | \seealso{ 76 | \code{\link[=tm_g_ipp]{tm_g_ipp()}} 77 | } 78 | \keyword{internal} 79 | -------------------------------------------------------------------------------- /man/template_laboratory.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_pp_laboratory.R 3 | \name{template_laboratory} 4 | \alias{template_laboratory} 5 | \title{Template: Patient Profile Laboratory Table} 6 | \usage{ 7 | template_laboratory( 8 | dataname = "ANL", 9 | paramcd = "PARAMCD", 10 | param = "PARAM", 11 | anrind = "ANRIND", 12 | timepoints = "ADY", 13 | aval = lifecycle::deprecated(), 14 | aval_var = "AVAL", 15 | avalu = lifecycle::deprecated(), 16 | avalu_var = "AVALU", 17 | patient_id = NULL, 18 | round_value = 0L 19 | ) 20 | } 21 | \arguments{ 22 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 23 | 24 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 25 | 26 | \item{param}{(\code{character})\cr name of the parameter variable.} 27 | 28 | \item{anrind}{(\code{character})\cr name of the analysis reference range indicator variable.} 29 | 30 | \item{timepoints}{(\code{character})\cr name of time variable.} 31 | 32 | \item{aval}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{aval_var} argument instead.} 33 | 34 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 35 | 36 | \item{avalu}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{avalu_var} argument instead.} 37 | 38 | \item{avalu_var}{(\code{character})\cr name of the analysis value unit variable.} 39 | 40 | \item{patient_id}{(\code{character})\cr patient ID.} 41 | 42 | \item{round_value}{(\code{numeric})\cr number of decimal places to round to.} 43 | } 44 | \value{ 45 | a \code{list} of expressions to generate a table or plot object. 46 | } 47 | \description{ 48 | Creates a valid expression to generate a patient profile laboratory table using ADaM datasets. 49 | } 50 | \seealso{ 51 | \code{\link[=tm_t_pp_laboratory]{tm_t_pp_laboratory()}} 52 | } 53 | \keyword{internal} 54 | -------------------------------------------------------------------------------- /man/template_logistic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_logistic.R 3 | \name{template_logistic} 4 | \alias{template_logistic} 5 | \title{Template: Logistic Regression} 6 | \usage{ 7 | template_logistic( 8 | dataname, 9 | arm_var, 10 | aval_var, 11 | paramcd = lifecycle::deprecated(), 12 | label_paramcd, 13 | cov_var, 14 | interaction_var, 15 | ref_arm, 16 | comp_arm, 17 | topleft = "Logistic Regression", 18 | conf_level = 0.95, 19 | combine_comp_arms = FALSE, 20 | responder_val = c("CR", "PR"), 21 | at = NULL, 22 | basic_table_args = teal.widgets::basic_table_args() 23 | ) 24 | } 25 | \arguments{ 26 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 27 | 28 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}. To fit a logistic model with no 29 | arm/treatment variable, set to \code{NULL}.} 30 | 31 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 32 | 33 | \item{paramcd}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} The \code{paramcd} argument is not used in this function.} 34 | 35 | \item{label_paramcd}{(\code{character})\cr label of response parameter value to print in the table title.} 36 | 37 | \item{cov_var}{(\code{character})\cr names of the covariates variables.} 38 | 39 | \item{interaction_var}{(\code{character})\cr names of the variables that can be used for interaction variable selection.} 40 | 41 | \item{ref_arm}{(\code{character})\cr the level of reference arm in case of arm comparison.} 42 | 43 | \item{comp_arm}{(\code{character})\cr the level of comparison arm in case of arm comparison.} 44 | 45 | \item{topleft}{(\code{character})\cr text to use as top-left annotation in the table.} 46 | 47 | \item{conf_level}{(\code{numeric})\cr value for the confidence level within the range of (0, 1).} 48 | 49 | \item{combine_comp_arms}{(\code{logical})\cr triggers the combination of comparison arms.} 50 | 51 | \item{responder_val}{(\code{character})\cr values of the responder variable corresponding with a successful response.} 52 | 53 | \item{at}{(\code{numeric} or \code{NULL})\cr optional values for the interaction variable. Otherwise the median is used.} 54 | 55 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 56 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 57 | module arguments (hard coded in the module body). 58 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 59 | } 60 | \value{ 61 | a \code{list} of expressions to generate a table or plot object. 62 | } 63 | \description{ 64 | Creates a valid expression to generate a logistic regression table. 65 | } 66 | \seealso{ 67 | \code{\link[=tm_t_logistic]{tm_t_logistic()}} 68 | } 69 | \keyword{internal} 70 | -------------------------------------------------------------------------------- /man/template_medical_history.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_pp_medical_history.R 3 | \name{template_medical_history} 4 | \alias{template_medical_history} 5 | \title{Template: Patient Profile Medical History} 6 | \usage{ 7 | template_medical_history( 8 | dataname = "ANL", 9 | mhterm = "MHTERM", 10 | mhbodsys = "MHBODSYS", 11 | mhdistat = "MHDISTAT", 12 | patient_id = NULL 13 | ) 14 | } 15 | \arguments{ 16 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 17 | 18 | \item{mhterm}{(\code{character})\cr name of the reported term for the medical history variable.} 19 | 20 | \item{mhbodsys}{(\code{character})\cr name of the body system or organ class variable.} 21 | 22 | \item{mhdistat}{(\code{character})\cr name of the status of the disease variable.} 23 | 24 | \item{patient_id}{(\code{character})\cr patient ID.} 25 | } 26 | \value{ 27 | a \code{list} of expressions to generate a table or plot object. 28 | } 29 | \description{ 30 | Creates a valid expression to generate a patient profile medical history report using ADaM datasets. 31 | } 32 | \seealso{ 33 | \code{\link[=tm_t_pp_medical_history]{tm_t_pp_medical_history()}} 34 | } 35 | \keyword{internal} 36 | -------------------------------------------------------------------------------- /man/template_mult_events.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_mult_events.R 3 | \name{template_mult_events} 4 | \alias{template_mult_events} 5 | \title{Template: Multiple Events by Term} 6 | \usage{ 7 | template_mult_events( 8 | dataname, 9 | parentname, 10 | arm_var, 11 | seq_var, 12 | hlt, 13 | llt, 14 | add_total = TRUE, 15 | total_label = default_total_label(), 16 | na_level = default_na_str(), 17 | event_type = "event", 18 | drop_arm_levels = TRUE, 19 | basic_table_args = teal.widgets::basic_table_args() 20 | ) 21 | } 22 | \arguments{ 23 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 24 | 25 | \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} 26 | 27 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 28 | 29 | \item{seq_var}{(\code{character})\cr name of analysis sequence number variable. Used for counting the unique number 30 | of events.} 31 | 32 | \item{hlt}{(\code{character})\cr name of the variable with high level term for events.} 33 | 34 | \item{llt}{(\code{character})\cr name of the variable with low level term for events.} 35 | 36 | \item{add_total}{(\code{logical})\cr whether to include column with total number of patients.} 37 | 38 | \item{total_label}{(\code{string})\cr string to display as total column/row label if column/row is 39 | enabled (see \code{add_total}). Defaults to \code{"All Patients"}. To set a new default \code{total_label} to 40 | apply in all modules, run \code{set_default_total_label("new_default")}.} 41 | 42 | \item{na_level}{(\code{string})\cr used to replace all \code{NA} or empty values 43 | in character or factor variables in the data. Defaults to \code{"<Missing>"}. To set a 44 | default \code{na_level} to apply in all modules, run \code{set_default_na_str("new_default")}.} 45 | 46 | \item{event_type}{(\code{character})\cr type of event that is summarized (e.g. adverse event, treatment). Default 47 | is \code{"event"}.} 48 | 49 | \item{drop_arm_levels}{(\code{logical})\cr whether to drop unused levels of \code{arm_var}. If \code{TRUE}, \code{arm_var} levels are 50 | set to those used in the \code{dataname} dataset. If \code{FALSE}, \code{arm_var} levels are set to those used in the 51 | \code{parentname} dataset. If \code{dataname} and \code{parentname} are the same, then \code{drop_arm_levels} is set to \code{TRUE} and 52 | user input for this parameter is ignored.} 53 | 54 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 55 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 56 | module arguments (hard coded in the module body). 57 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 58 | } 59 | \value{ 60 | a \code{list} of expressions to generate a table or plot object. 61 | } 62 | \description{ 63 | Creates a valid expression to generate a table of multiple events by term. 64 | } 65 | \seealso{ 66 | \code{\link[=tm_t_mult_events]{tm_t_mult_events()}} 67 | } 68 | \keyword{internal} 69 | -------------------------------------------------------------------------------- /man/template_patient_timeline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_g_pp_patient_timeline.R 3 | \name{template_patient_timeline} 4 | \alias{template_patient_timeline} 5 | \title{Template: Patient Profile Timeline Plot} 6 | \usage{ 7 | template_patient_timeline( 8 | dataname = "ANL", 9 | aeterm = "AETERM", 10 | aetime_start = "ASTDTM", 11 | aetime_end = "AENDTM", 12 | dstime_start = "CMASTDTM", 13 | dstime_end = "CMAENDTM", 14 | cmdecod = "CMDECOD", 15 | aerelday_start = NULL, 16 | aerelday_end = NULL, 17 | dsrelday_start = NULL, 18 | dsrelday_end = NULL, 19 | relative_day = FALSE, 20 | patient_id, 21 | font_size = 12L, 22 | ggplot2_args = teal.widgets::ggplot2_args() 23 | ) 24 | } 25 | \arguments{ 26 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 27 | 28 | \item{aeterm}{(\code{character})\cr name of the reported term for the adverse event variable.} 29 | 30 | \item{aetime_start}{(\code{character})\cr name of start date/time of adverse event variable.} 31 | 32 | \item{aetime_end}{(\code{character})\cr name of end date/time of adverse event variable.} 33 | 34 | \item{dstime_start}{(\code{character})\cr name of date/time of first exposure to treatment variable.} 35 | 36 | \item{dstime_end}{(\code{character})\cr name of date/time of last exposure to treatment variable.} 37 | 38 | \item{cmdecod}{(\code{character})\cr name of standardized medication name variable.} 39 | 40 | \item{aerelday_start}{(\code{character})\cr name of adverse event study start day variable.} 41 | 42 | \item{aerelday_end}{(\code{character})\cr name of adverse event study end day variable.} 43 | 44 | \item{dsrelday_start}{(\code{character})\cr name of concomitant medications study start day variable.} 45 | 46 | \item{dsrelday_end}{(\code{character})\cr name of concomitant medications study day start variable.} 47 | 48 | \item{relative_day}{(\code{logical})\cr whether to use relative days (\code{TRUE}) or absolute dates (\code{FALSE}).} 49 | 50 | \item{patient_id}{(\code{character})\cr patient ID.} 51 | 52 | \item{font_size}{(\code{numeric})\cr font size value.} 53 | 54 | \item{ggplot2_args}{(\code{ggplot2_args}) optional\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings 55 | for the module plot. The argument is merged with option \code{teal.ggplot2_args} and with default module arguments 56 | (hard coded in the module body). 57 | For more details, see the vignette: \code{vignette("custom-ggplot2-arguments", package = "teal.widgets")}.} 58 | } 59 | \value{ 60 | a \code{list} of expressions to generate a table or plot object. 61 | } 62 | \description{ 63 | Creates a valid expression to generate a patient profile timeline \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} plot using ADaM datasets. 64 | } 65 | \seealso{ 66 | \code{\link[=tm_g_pp_patient_timeline]{tm_g_pp_patient_timeline()}} 67 | } 68 | \keyword{internal} 69 | -------------------------------------------------------------------------------- /man/template_prior_medication.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_pp_prior_medication.R 3 | \name{template_prior_medication} 4 | \alias{template_prior_medication} 5 | \title{Template: Patient Profile Prior Medication} 6 | \usage{ 7 | template_prior_medication( 8 | dataname = "ANL", 9 | atirel = "ATIREL", 10 | cmdecod = "CMDECOD", 11 | cmindc = "CMINDC", 12 | cmstdy = "CMSTDY" 13 | ) 14 | } 15 | \arguments{ 16 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 17 | 18 | \item{atirel}{(\code{character})\cr name of time relation of medication variable.} 19 | 20 | \item{cmdecod}{(\code{character})\cr name of standardized medication name variable.} 21 | 22 | \item{cmindc}{(\code{character})\cr name of indication variable.} 23 | 24 | \item{cmstdy}{(\code{character})\cr name of study relative day of start of medication variable.} 25 | } 26 | \value{ 27 | a \code{list} of expressions to generate a table or plot object. 28 | } 29 | \description{ 30 | Creates a valid expression to generate a patient profile prior medication report using ADaM datasets. 31 | } 32 | \seealso{ 33 | \code{\link[=tm_t_pp_prior_medication]{tm_t_pp_prior_medication()}} 34 | } 35 | \keyword{internal} 36 | -------------------------------------------------------------------------------- /man/template_shift_by_arm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_t_shift_by_arm.R 3 | \name{template_shift_by_arm} 4 | \alias{template_shift_by_arm} 5 | \title{Template: Shift by Arm} 6 | \usage{ 7 | template_shift_by_arm( 8 | dataname, 9 | parentname, 10 | arm_var = "ARM", 11 | paramcd = "PARAMCD", 12 | visit_var = "AVISIT", 13 | treatment_flag_var = "ONTRTFL", 14 | treatment_flag = "Y", 15 | aval_var = "ANRIND", 16 | base_var = lifecycle::deprecated(), 17 | baseline_var = "BNRIND", 18 | na.rm = FALSE, 19 | na_level = default_na_str(), 20 | add_total = FALSE, 21 | total_label = default_total_label(), 22 | basic_table_args = teal.widgets::basic_table_args() 23 | ) 24 | } 25 | \arguments{ 26 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 27 | 28 | \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} 29 | 30 | \item{arm_var}{(\code{character})\cr variable names that can be used as \code{arm_var}.} 31 | 32 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 33 | 34 | \item{visit_var}{(\code{character})\cr variable names that can be used as \code{visit} variable. Must be a factor in 35 | \code{dataname}.} 36 | 37 | \item{treatment_flag_var}{(\code{character})\cr name of the on treatment flag variable.} 38 | 39 | \item{treatment_flag}{(\code{character})\cr name of the value indicating on treatment 40 | records in \code{treatment_flag_var}.} 41 | 42 | \item{aval_var}{(\code{character})\cr name of the analysis reference range indicator variable.} 43 | 44 | \item{base_var}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{baseline_var} argument instead.} 45 | 46 | \item{baseline_var}{(\code{character})\cr name of the baseline reference range indicator variable.} 47 | 48 | \item{na.rm}{(\code{logical})\cr whether \code{NA} values should be removed prior to analysis.} 49 | 50 | \item{na_level}{(\code{string})\cr used to replace all \code{NA} or empty values 51 | in character or factor variables in the data. Defaults to \code{"<Missing>"}. To set a 52 | default \code{na_level} to apply in all modules, run \code{set_default_na_str("new_default")}.} 53 | 54 | \item{add_total}{(\code{logical})\cr whether to include row with total number of patients.} 55 | 56 | \item{total_label}{(\code{string})\cr string to display as total column/row label if column/row is 57 | enabled (see \code{add_total}). Defaults to \code{"All Patients"}. To set a new default \code{total_label} to 58 | apply in all modules, run \code{set_default_total_label("new_default")}.} 59 | 60 | \item{basic_table_args}{(\code{basic_table_args}) optional\cr object created by \code{\link[teal.widgets:basic_table_args]{teal.widgets::basic_table_args()}} 61 | with settings for the module table. The argument is merged with option \code{teal.basic_table_args} and with default 62 | module arguments (hard coded in the module body). 63 | For more details, see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}.} 64 | } 65 | \value{ 66 | a \code{list} of expressions to generate a table or plot object. 67 | } 68 | \description{ 69 | Creates a valid expression to generate a summary table of analysis indicator levels by arm. 70 | } 71 | \seealso{ 72 | \code{\link[=tm_t_shift_by_arm]{tm_t_shift_by_arm()}} 73 | } 74 | \keyword{internal} 75 | -------------------------------------------------------------------------------- /man/template_therapy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_g_pp_therapy.R 3 | \name{template_therapy} 4 | \alias{template_therapy} 5 | \title{Template: Patient Profile Therapy Table and Plot} 6 | \usage{ 7 | template_therapy( 8 | dataname = "ANL", 9 | atirel = "ATIREL", 10 | cmdecod = "CMDECOD", 11 | cmindc = "CMINDC", 12 | cmdose = "CMDOSE", 13 | cmtrt = "CMTRT", 14 | cmdosu = "CMDOSU", 15 | cmroute = "CMROUTE", 16 | cmdosfrq = "CMDOSFRQ", 17 | cmstdy = "CMSTDY", 18 | cmendy = "CMENDY", 19 | patient_id, 20 | font_size = 12L, 21 | ggplot2_args = teal.widgets::ggplot2_args() 22 | ) 23 | } 24 | \arguments{ 25 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 26 | 27 | \item{atirel}{(\code{character})\cr name of time relation of medication variable.} 28 | 29 | \item{cmdecod}{(\code{character})\cr name of standardized medication name variable.} 30 | 31 | \item{cmindc}{(\code{character})\cr name of indication variable.} 32 | 33 | \item{cmdose}{(\code{character})\cr name of dose per administration variable.} 34 | 35 | \item{cmtrt}{(\code{character})\cr name of reported name of drug, med, or therapy variable.} 36 | 37 | \item{cmdosu}{(\code{character})\cr name of dose units variable.} 38 | 39 | \item{cmroute}{(\code{character})\cr name of route of administration variable.} 40 | 41 | \item{cmdosfrq}{(\code{character})\cr name of dosing frequency per interval variable.} 42 | 43 | \item{cmstdy}{(\code{character})\cr name of study relative day of start of medication variable.} 44 | 45 | \item{cmendy}{(\code{character})\cr name of study day of end of medication variable.} 46 | 47 | \item{patient_id}{(\code{character})\cr patient ID.} 48 | 49 | \item{font_size}{(\code{numeric})\cr font size value.} 50 | 51 | \item{ggplot2_args}{(\code{ggplot2_args}) optional\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings 52 | for the module plot. The argument is merged with option \code{teal.ggplot2_args} and with default module arguments 53 | (hard coded in the module body). 54 | For more details, see the vignette: \code{vignette("custom-ggplot2-arguments", package = "teal.widgets")}.} 55 | } 56 | \value{ 57 | a \code{list} of expressions to generate a table or plot object. 58 | } 59 | \description{ 60 | Creates a valid expression to generate a patient profile therapy table and \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} plot using ADaM 61 | datasets. 62 | } 63 | \seealso{ 64 | \code{\link[=tm_g_pp_therapy]{tm_g_pp_therapy()}} 65 | } 66 | \keyword{internal} 67 | -------------------------------------------------------------------------------- /man/template_vitals.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tm_g_pp_vitals.R 3 | \name{template_vitals} 4 | \alias{template_vitals} 5 | \title{Template: Patient Profile Vitals Plot} 6 | \usage{ 7 | template_vitals( 8 | dataname = "ANL", 9 | paramcd = "PARAMCD", 10 | paramcd_levels = c("SYSBP", "DIABP", "PUL", "RESP", "OXYSAT", "WGHT", "TEMP"), 11 | xaxis = "ADY", 12 | aval = lifecycle::deprecated(), 13 | aval_var = "AVAL", 14 | patient_id, 15 | font_size = 12L, 16 | ggplot2_args = teal.widgets::ggplot2_args() 17 | ) 18 | } 19 | \arguments{ 20 | \item{dataname}{(\code{character})\cr analysis data used in teal module.} 21 | 22 | \item{paramcd}{(\code{character})\cr name of the parameter code variable.} 23 | 24 | \item{paramcd_levels}{(\code{character})\cr vector of all levels of \code{paramcd}.} 25 | 26 | \item{xaxis}{(\code{character})\cr name of the time variable to put on the x-axis.} 27 | 28 | \item{aval}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{aval_var} argument instead.} 29 | 30 | \item{aval_var}{(\code{character})\cr name of the analysis value variable.} 31 | 32 | \item{patient_id}{(\code{character})\cr patient ID.} 33 | 34 | \item{font_size}{(\code{numeric})\cr font size value.} 35 | 36 | \item{ggplot2_args}{(\code{ggplot2_args}) optional\cr object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings 37 | for the module plot. The argument is merged with option \code{teal.ggplot2_args} and with default module arguments 38 | (hard coded in the module body). 39 | For more details, see the vignette: \code{vignette("custom-ggplot2-arguments", package = "teal.widgets")}.} 40 | } 41 | \value{ 42 | a \code{list} of expressions to generate a table or plot object. 43 | } 44 | \description{ 45 | Creates a valid expression to generate a patient profile vitals \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} plot using ADaM datasets. 46 | } 47 | \seealso{ 48 | \code{\link[=tm_g_pp_vitals]{tm_g_pp_vitals()}} 49 | } 50 | \keyword{internal} 51 | -------------------------------------------------------------------------------- /man/validate_arm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/validate_standard_inputs.R 3 | \name{validate_arm} 4 | \alias{validate_arm} 5 | \title{Check if vector is valid as to be used as a treatment arm variable} 6 | \usage{ 7 | validate_arm(arm_vec) 8 | } 9 | \arguments{ 10 | \item{arm_vec}{vector to be validated} 11 | } 12 | \description{ 13 | Check if vector is valid as to be used as a treatment arm variable 14 | } 15 | \details{ 16 | A validate error is returned if the vector is not a factor with a more detailed 17 | error message if any of the entries are empty strings 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /man/validate_standard_inputs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/validate_standard_inputs.R 3 | \name{validate_standard_inputs} 4 | \alias{validate_standard_inputs} 5 | \title{Validate standard input values for a teal module} 6 | \usage{ 7 | validate_standard_inputs( 8 | adsl, 9 | adslvars = character(0), 10 | anl, 11 | anlvars = character(0), 12 | need_arm = TRUE, 13 | arm_var, 14 | ref_arm, 15 | comp_arm, 16 | min_n_levels_armvar = 1L, 17 | max_n_levels_armvar = 100L, 18 | min_nrow = 1 19 | ) 20 | } 21 | \arguments{ 22 | \item{adsl}{data.frame with subject-level data} 23 | 24 | \item{adslvars}{required variables from \code{ADSL}} 25 | 26 | \item{anl}{data.frame with analysis data} 27 | 28 | \item{anlvars}{required variables from \code{ANL}} 29 | 30 | \item{need_arm}{flag indicating whether grouping variable \code{arm_var} 31 | is required or can be optionally \code{NULL}.} 32 | 33 | \item{arm_var}{character with name of grouping variable, typically arm} 34 | 35 | \item{ref_arm}{character with name of reference level in \code{arm_var}} 36 | 37 | \item{comp_arm}{character with name for comparison level in \code{arm_var}} 38 | 39 | \item{min_n_levels_armvar}{minimum number of levels in grouping variable \code{arm_var}. 40 | Defaults to 1, \code{NULL} for no minimum.} 41 | 42 | \item{max_n_levels_armvar}{maximum number of levels in grouping variable \code{arm_var}. 43 | Use \code{NULL} for no maximum.} 44 | 45 | \item{min_nrow}{minimum number of observations in \code{ADSL} and \code{ANL}} 46 | } 47 | \description{ 48 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} 49 | } 50 | \keyword{internal} 51 | -------------------------------------------------------------------------------- /revdep/.gitignore: -------------------------------------------------------------------------------- 1 | checks 2 | library 3 | checks.noindex 4 | library.noindex 5 | cloud.noindex 6 | data.sqlite 7 | *.html 8 | -------------------------------------------------------------------------------- /staged_dependencies.yaml: -------------------------------------------------------------------------------- 1 | current_repo: 2 | repo: insightsengineering/teal.modules.clinical 3 | host: https://github.com 4 | upstream_repos: 5 | insightsengineering/tern: 6 | repo: insightsengineering/tern 7 | host: https://github.com 8 | insightsengineering/tern.mmrm: 9 | repo: insightsengineering/tern.mmrm 10 | host: https://github.com 11 | insightsengineering/tern.gee: 12 | repo: insightsengineering/tern.gee 13 | host: https://github.com 14 | insightsengineering/rlistings: 15 | repo: insightsengineering/rlistings 16 | host: https://github.com 17 | insightsengineering/rtables: 18 | repo: insightsengineering/rtables 19 | host: https://github.com 20 | insightsengineering/teal.logger: 21 | repo: insightsengineering/teal.logger 22 | host: https://github.com 23 | insightsengineering/teal.reporter: 24 | repo: insightsengineering/teal.reporter 25 | host: https://github.com 26 | insightsengineering/teal.widgets: 27 | repo: insightsengineering/teal.widgets 28 | host: https://github.com 29 | insightsengineering/teal.code: 30 | repo: insightsengineering/teal.code 31 | host: https://github.com 32 | insightsengineering/teal.data: 33 | repo: insightsengineering/teal.data 34 | host: https://github.com 35 | insightsengineering/teal.transform: 36 | repo: insightsengineering/teal.transform 37 | host: https://github.com 38 | insightsengineering/teal: 39 | repo: insightsengineering/teal 40 | host: https://github.com 41 | insightsengineering/nestcolor: 42 | repo: insightsengineering/nestcolor 43 | host: https://github.com 44 | insightsengineering/roxy.shinylive: 45 | repo: insightsengineering/roxy.shinylive 46 | host: https://github.com 47 | downstream_repos: 48 | -------------------------------------------------------------------------------- /teal.modules.clinical.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: 30e7a67f-08e0-4dde-9d81-bc610ab7cf3e 3 | 4 | RestoreWorkspace: No 5 | SaveWorkspace: No 6 | AlwaysSaveHistory: No 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 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | pkg_name <- "teal.modules.clinical" 2 | library(pkg_name, character.only = TRUE) 3 | testthat::test_check(pkg_name) 4 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tm_a_gee.md: -------------------------------------------------------------------------------- 1 | # template_a_gee t_gee_cov table works as expected with default input 2 | 3 | Code 4 | res 5 | Output 6 | $model 7 | { 8 | model_fit <- tern.gee::fit_gee(vars = tern.gee::vars_gee(response = as.vector("AVAL"), 9 | covariates = as.vector(NULL), id = as.vector("USUBJID"), 10 | arm = as.vector("ARMCD"), visit = as.vector("AVISIT")), 11 | data = ANL, regression = "logistic", cor_struct = "unstructured") 12 | } 13 | 14 | $table 15 | { 16 | table <- tern.gee::as.rtable(model_fit, type = "cov") 17 | subtitles(table) <- NULL 18 | main_footer(table) <- NULL 19 | } 20 | 21 | 22 | # template_a_gee t_gee_coef table works as expected with default input 23 | 24 | Code 25 | res 26 | Output 27 | $model 28 | { 29 | model_fit <- tern.gee::fit_gee(vars = tern.gee::vars_gee(response = as.vector("AVAL"), 30 | covariates = as.vector(NULL), id = as.vector("USUBJID"), 31 | arm = as.vector("ARMCD"), visit = as.vector("AVISIT")), 32 | data = ANL, regression = "logistic", cor_struct = "unstructured") 33 | } 34 | 35 | $table 36 | { 37 | table <- tern.gee::as.rtable(data.frame(Coefficient = model_fit$coefficients)) 38 | subtitles(table) <- NULL 39 | main_footer(table) <- NULL 40 | } 41 | 42 | 43 | # template_a_gee works as expected with non-default reference arm 44 | 45 | Code 46 | res 47 | Output 48 | $model 49 | { 50 | model_fit <- tern.gee::fit_gee(vars = tern.gee::vars_gee(response = as.vector("AVAL"), 51 | covariates = as.vector(NULL), id = as.vector("USUBJID"), 52 | arm = as.vector("ARMCD"), visit = as.vector("AVISIT")), 53 | data = ANL, regression = "logistic", cor_struct = "unstructured") 54 | } 55 | 56 | $table 57 | { 58 | lsmeans_fit_model <- tern.gee::lsmeans(model_fit, 0.95) 59 | table <- rtables::basic_table(show_colcounts = TRUE) %>% 60 | rtables::split_cols_by(var = "ARM", ref_group = model_fit$ref_level) %>% 61 | tern.gee::summarize_gee_logistic() %>% rtables::build_table(df = lsmeans_fit_model, 62 | alt_counts_df = ANL_ADSL) 63 | subtitles(table) <- NULL 64 | main_footer(table) <- NULL 65 | } 66 | 67 | 68 | # template_a_gee works as expected when arm is not considered in the model 69 | 70 | Code 71 | res 72 | Output 73 | $model 74 | { 75 | model_fit <- tern.gee::fit_gee(vars = tern.gee::vars_gee(response = as.vector("AVAL"), 76 | covariates = as.vector(NULL), id = as.vector("USUBJID"), 77 | arm = as.vector(NULL), visit = as.vector("AVISIT")), 78 | data = ANL, regression = "logistic", cor_struct = "unstructured") 79 | } 80 | 81 | $table 82 | { 83 | lsmeans_fit_model <- tern.gee::lsmeans(model_fit, 0.95) 84 | table <- rtables::basic_table(show_colcounts = TRUE) %>% 85 | rtables::split_cols_by(var = "ARM", ref_group = model_fit$ref_level) %>% 86 | tern.gee::summarize_gee_logistic() %>% rtables::build_table(df = lsmeans_fit_model, 87 | alt_counts_df = ANL_ADSL) 88 | subtitles(table) <- NULL 89 | main_footer(table) <- NULL 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tm_g_ci.md: -------------------------------------------------------------------------------- 1 | # 1. and 2. Mean and 95% CIs for mean 2 | 3 | Code 4 | res 5 | Output 6 | { 7 | plot <- ggplot2::ggplot(data = ANL, mapping = ggplot2::aes(x = ARMCD, 8 | y = AVAL, color = SEX, lty = SEX, shape = SEX)) + ggplot2::stat_summary(fun.data = stat_mean_ci, 9 | geom = "errorbar", width = 0.1, position = ggplot2::position_dodge(width = 0.5)) + 10 | ggplot2::stat_summary(fun = mean, geom = "point", position = ggplot2::position_dodge(width = 0.5)) + 11 | ggplot2::labs(title = "Confidence Interval Plot by Treatment Group", 12 | caption = "Mean and 95% CIs for mean are displayed.", 13 | x = "Treatment Group", y = "Value", color = "", lty = "", 14 | shape = "") 15 | } 16 | 17 | # 3. Confidence Interval Plot (using different stratification variable) 18 | 19 | Code 20 | res 21 | Output 22 | { 23 | plot <- ggplot2::ggplot(data = ANL, mapping = ggplot2::aes(x = ARMCD, 24 | y = AVAL, color = STRATA2, lty = STRATA2, shape = STRATA2)) + 25 | ggplot2::stat_summary(fun.data = stat_mean_ci, geom = "errorbar", 26 | width = 0.1, position = ggplot2::position_dodge(width = 0.5)) + 27 | ggplot2::stat_summary(fun = mean, geom = "point", position = ggplot2::position_dodge(width = 0.5)) + 28 | ggplot2::labs(title = "Confidence Interval Plot by Treatment Group", 29 | caption = "Mean and 95% CIs for mean are displayed.", 30 | x = "Treatment Group", y = "Value", color = "", lty = "", 31 | shape = "") 32 | } 33 | 34 | # 4. Median and 95% CIs for median 35 | 36 | Code 37 | res 38 | Output 39 | { 40 | plot <- ggplot2::ggplot(data = ANL, mapping = ggplot2::aes(x = ARMCD, 41 | y = AVAL, color = STRATA1, lty = STRATA1, shape = STRATA1)) + 42 | ggplot2::stat_summary(fun.data = stat_median_ci, geom = "errorbar", 43 | width = 0.1, position = ggplot2::position_dodge(width = 0.5)) + 44 | ggplot2::stat_summary(fun = median, geom = "point", position = ggplot2::position_dodge(width = 0.5)) + 45 | ggplot2::labs(title = "Confidence Interval Plot by Treatment Group", 46 | caption = "Median and 95% CIs for median are displayed.", 47 | x = "Treatment Group", y = "Value", color = "", lty = "", 48 | shape = "") 49 | } 50 | 51 | # 5. Using different alpha level 52 | 53 | Code 54 | res 55 | Output 56 | { 57 | plot <- ggplot2::ggplot(data = ANL, mapping = ggplot2::aes(x = ARMCD, 58 | y = AVAL, color = SEX, lty = SEX, shape = SEX)) + ggplot2::stat_summary(fun.data = function(x) stat_mean_ci(x, 59 | conf_level = 0.9), geom = "errorbar", width = 0.1, position = ggplot2::position_dodge(width = 0.5)) + 60 | ggplot2::stat_summary(fun = mean, geom = "point", position = ggplot2::position_dodge(width = 0.5)) + 61 | ggplot2::labs(title = "Confidence Interval Plot by Treatment Group", 62 | caption = "Mean and 90% CIs for mean are displayed.", 63 | x = "Treatment Group", y = "Value", color = "", lty = "", 64 | shape = "") 65 | } 66 | 67 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tm_g_ipp.md: -------------------------------------------------------------------------------- 1 | # template_g_ipp works as expected with default arguments 2 | 3 | Code 4 | res 5 | Output 6 | $data 7 | anl <- ANL %>% droplevels() 8 | 9 | $graph 10 | { 11 | plot <- h_g_ipp(df = anl, xvar = "AVISIT", yvar = "AVAL", 12 | xlab = "Visit", ylab = "e (d)", title = "Individual Patient Plot for e Values (d) over Time", 13 | subtitle = "a, b, c", id_var = "USUBJID", add_baseline_hline = FALSE, 14 | yvar_baseline = "BASE") 15 | grid::grid.newpage() 16 | grid::grid.draw(plot) 17 | } 18 | 19 | 20 | # template_g_ipp works as expected with non-default arguments 21 | 22 | Code 23 | res 24 | Output 25 | $data 26 | anl <- adlb %>% droplevels() 27 | 28 | $graph 29 | { 30 | plot <- h_g_ipp(df = anl, xvar = "AVISIT", yvar = "AVAL", 31 | xlab = "Visit", ylab = "e (d)", title = "Individual Patient Plot for e Values (d) over Time", 32 | subtitle = "a, b, c", id_var = "SUBJID", add_baseline_hline = TRUE, 33 | yvar_baseline = "BASE") 34 | plot <- plot + ggplot2::facet_grid(rows = ggplot2::vars(SUBJID)) 35 | grid::grid.newpage() 36 | grid::grid.draw(plot) 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tm_g_lineplot.md: -------------------------------------------------------------------------------- 1 | # template_g_lineplot works as expected with default arguments 2 | 3 | Code 4 | res 5 | Output 6 | $data 7 | { 8 | anl <- ANL %>% dplyr::mutate(ARM = droplevels(ARM)) 9 | } 10 | 11 | $variables 12 | variables <- control_lineplot_vars(x = "AVISIT", y = "AVAL", 13 | group_var = "ARM", paramcd = "PARAMCD", y_unit = "AVALU") 14 | 15 | $graph 16 | { 17 | grid::grid.newpage() 18 | plot <- g_lineplot(df = anl, variables = variables, interval = "mean_ci", 19 | mid = "mean", whiskers = c("mean_ci_lwr", "mean_ci_upr"), 20 | table = c("n", "mean_sd", "median", "range"), mid_type = "pl", 21 | mid_point_size = 2, table_font_size = 4, newpage = FALSE, 22 | title = "Plot of Mean and 95% Mean Confidence Interval of AVAL by Visit", 23 | subtitle = "", caption = NULL, y_lab = "AVAL Mean Values for", 24 | legend_title = NULL, ggtheme = ggplot2::theme_minimal(), 25 | control = control_analyze_vars(conf_level = 0.95), subtitle_add_paramcd = FALSE, 26 | subtitle_add_unit = FALSE) 27 | } 28 | 29 | 30 | # template_g_lineplot gives correct data expression with custom arguments 31 | 32 | Code 33 | res 34 | Output 35 | $data 36 | { 37 | anl <- ANL %>% dplyr::filter(AVISIT != "SCREENING") %>% dplyr::mutate(AVISIT = factor(AVISIT)) %>% 38 | dplyr::mutate(ARMCD = droplevels(ARMCD)) 39 | } 40 | 41 | $variables 42 | variables <- control_lineplot_vars(x = "AVISIT", y = "CHG", group_var = "ARMCD", 43 | paramcd = "PARAMCD", y_unit = "AVALU") 44 | 45 | $graph 46 | { 47 | grid::grid.newpage() 48 | plot <- g_lineplot(df = anl, variables = variables, interval = "median_ci", 49 | mid = "median", whiskers = "median_ci_upr", table = c("mean_sd", 50 | "median", "median_ci"), mid_type = "l", mid_point_size = 2, 51 | table_font_size = 4, newpage = FALSE, title = "Plot of Median and 90% Median Confidence Interval of CHG by Visit", 52 | subtitle = "", caption = NULL, y_lab = "CHG Median Values for", 53 | legend_title = NULL, ggtheme = ggplot2::theme_minimal(), 54 | control = control_analyze_vars(conf_level = 0.9), subtitle_add_paramcd = FALSE, 55 | subtitle_add_unit = FALSE) 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tm_t_pp_medical_history.md: -------------------------------------------------------------------------------- 1 | # template_medical_history - non-default parameters 2 | 3 | Code 4 | res 5 | Output 6 | { 7 | labels <- teal.data::col_labels(anl, fill = FALSE)[c("mhbodsys", 8 | "mhterm", "mhdistat")] 9 | mhbodsys_label <- labels["mhbodsys"] 10 | result_raw <- anl %>% dplyr::select(mhbodsys, mhterm, mhdistat) %>% 11 | dplyr::arrange(mhbodsys) %>% dplyr::mutate_if(is.character, 12 | as.factor) %>% dplyr::mutate_if(is.factor, function(x) explicit_na(x, 13 | "UNKNOWN")) %>% dplyr::distinct() %>% `colnames<-`(labels) 14 | table <- rtables::basic_table() %>% rtables::split_cols_by_multivar(colnames(result_raw)[2:3]) %>% 15 | rtables::split_rows_by(colnames(result_raw)[1], split_fun = rtables::drop_split_levels) %>% 16 | rtables::split_rows_by(colnames(result_raw)[2], split_fun = rtables::drop_split_levels, 17 | child_labels = "hidden") %>% rtables::analyze_colvars(function(x) x[seq_along(x)]) %>% 18 | rtables::build_table(result_raw) 19 | main_title(table) <- paste("Patient ID:", NULL) 20 | } 21 | 22 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/tm_t_shift_by_arm.md: -------------------------------------------------------------------------------- 1 | # template_shift_by_arm generates correct expressions with default arguments 2 | 3 | Code 4 | res 5 | Output 6 | $data 7 | { 8 | adsl <- df_explicit_na(adsl, na_level = "<Missing>") 9 | adeg <- df_explicit_na(adeg, na_level = "<Missing>") %>% 10 | dplyr::filter(ONTRTFL == "Y") 11 | attr(adeg$BNRIND, "label") <- "Baseline Assessment" 12 | } 13 | 14 | $layout 15 | lyt <- rtables::basic_table() %>% rtables::split_cols_by("AVISIT", 16 | split_fun = drop_split_levels) %>% rtables::split_cols_by("ANRIND") %>% 17 | rtables::split_rows_by("ARM", split_fun = drop_split_levels, 18 | label_pos = "topleft", split_label = obj_label(adeg$ARM)) %>% 19 | add_rowcounts() %>% analyze_vars("BNRIND", denom = "N_row", 20 | na_str = "<Missing>", na.rm = FALSE, .stats = "count_fraction") %>% 21 | append_varlabels(adeg, "BNRIND", indent = 1L) 22 | 23 | $table 24 | { 25 | table <- rtables::build_table(lyt = lyt, df = adeg) 26 | } 27 | 28 | 29 | # template_shift_by_arm generates correct expressions with add_total being TRUE 30 | 31 | Code 32 | res 33 | Output 34 | $data 35 | { 36 | adsl <- df_explicit_na(adsl, na_level = "<Missing>") 37 | adeg <- df_explicit_na(adeg, na_level = "<Missing>") %>% 38 | dplyr::filter(ONTRTFL == "Y") 39 | attr(adeg$BNRIND, "label") <- "Baseline Assessment" 40 | } 41 | 42 | $layout 43 | lyt <- rtables::basic_table() %>% rtables::split_cols_by("AVISIT", 44 | split_fun = drop_split_levels) %>% rtables::split_cols_by("ANRIND") %>% 45 | rtables::split_rows_by("ARM", split_fun = add_overall_level("All Patients", 46 | first = FALSE), label_pos = "topleft", split_label = obj_label(adeg$ARM)) %>% 47 | add_rowcounts() %>% analyze_vars("BNRIND", denom = "N_row", 48 | na_str = "<Missing>", na.rm = FALSE, .stats = "count_fraction") %>% 49 | append_varlabels(adeg, "BNRIND", indent = 1L) 50 | 51 | $table 52 | { 53 | table <- rtables::build_table(lyt = lyt, df = adeg) 54 | } 55 | 56 | 57 | # template_shift_by_arm generates correct expressions with na.rm being TRUE 58 | 59 | Code 60 | res 61 | Output 62 | $data 63 | { 64 | adsl <- df_explicit_na(adsl, na_level = "<Missing>") 65 | adeg <- df_explicit_na(adeg, na_level = "<Missing>") %>% 66 | dplyr::filter(ONTRTFL == "Y") 67 | attr(adeg$BNRIND, "label") <- "Baseline Assessment" 68 | } 69 | 70 | $layout 71 | lyt <- rtables::basic_table() %>% rtables::split_cols_by("AVISIT", 72 | split_fun = drop_split_levels) %>% rtables::split_cols_by("ANRIND") %>% 73 | rtables::split_rows_by("ARM", split_fun = drop_split_levels, 74 | label_pos = "topleft", split_label = obj_label(adeg$ARM)) %>% 75 | add_rowcounts() %>% analyze_vars("BNRIND", denom = "N_row", 76 | na_str = "<Missing>", na.rm = TRUE, .stats = "count_fraction") %>% 77 | append_varlabels(adeg, "BNRIND", indent = 1L) 78 | 79 | $table 80 | { 81 | table <- rtables::build_table(lyt = lyt, df = adeg) 82 | } 83 | 84 | 85 | -------------------------------------------------------------------------------- /tests/testthat/helper-TealAppDriver.R: -------------------------------------------------------------------------------- 1 | # Initialization function to create a new TealAppDriver object 2 | # 3 | # By manipulating the server function as below, we can hint {shinytest2} to load 4 | # this package and its "Depends". 5 | # Related to https://github.com/rstudio/shinytest2/issues/381 6 | init_teal_app_driver <- function(...) { 7 | testthat::with_mocked_bindings( 8 | { 9 | TealAppDriver <- getFromNamespace("TealAppDriver", "teal") # nolint: object_name. 10 | TealAppDriver$new(...) 11 | }, 12 | shinyApp = function(ui, server, ...) { 13 | functionBody(server) <- bquote({ 14 | # Hint to shinytest2 that this package should be available (via {globals}) 15 | .hint_to_load_package <- tm_g_ci # Hint to shinytest2 when looking for packages in globals 16 | .(functionBody(server)) 17 | }) 18 | 19 | shiny::shinyApp(ui, server, ...) 20 | }, 21 | # The relevant shinyApp call in `TealAppDriver` is being called without prefix, 22 | # hence why the package bindings that is changed is in {teal} and not {shiny} 23 | .package = "teal" 24 | ) 25 | } 26 | 27 | ns_des_input <- function(id, dataname, type) { 28 | sprintf("%s-dataset_%s_singleextract-%s", id, dataname, type) 29 | } 30 | -------------------------------------------------------------------------------- /tests/testthat/helper-testing-depth.R: -------------------------------------------------------------------------------- 1 | #' Returns testing depth set by session option or by environmental variable. 2 | #' 3 | #' @details Looks for the session option `TESTING_DEPTH` first. 4 | #' If not set, takes the system environmental variable `TESTING_DEPTH`. 5 | #' If neither is set, then returns 3 by default. 6 | #' If the value of `TESTING_DEPTH` is not a numeric of length 1, then returns 3. 7 | #' 8 | #' @return `numeric(1)` the testing depth. 9 | #' 10 | get_testing_depth <- function() { 11 | default_depth <- 3 12 | depth <- getOption("TESTING_DEPTH", Sys.getenv("TESTING_DEPTH", default_depth)) 13 | depth <- tryCatch( 14 | as.numeric(depth), 15 | error = function(error) default_depth, 16 | warning = function(warning) default_depth 17 | ) 18 | if (length(depth) != 1) depth <- default_depth 19 | depth 20 | } 21 | 22 | #' Skipping tests in the testthat pipeline under specific scope 23 | #' @description This function should be used per each `testthat::test_that` call. 24 | #' Each of the call should specify an appropriate depth value. 25 | #' The depth value will set the appropriate scope so more/less time consuming tests could be recognized. 26 | #' The environment variable `TESTING_DEPTH` is used for changing the scope of `testthat` pipeline. 27 | #' `TESTING_DEPTH` interpretation for each possible value: 28 | #' \itemize{ 29 | #' \item{0}{no tests at all} 30 | #' \item{1}{fast - small scope - executed on every commit} 31 | #' \item{3}{medium - medium scope - daily integration pipeline} 32 | #' \item{5}{slow - all tests - daily package tests} 33 | #' } 34 | #' @param depth `numeric` the depth of the testing evaluation, 35 | #' has opposite interpretation to environment variable `TESTING_DEPTH`. 36 | #' So e.g. `0` means run it always and `5` means a heavy test which should be run rarely. 37 | #' If the `depth` argument is larger than `TESTING_DEPTH` then the test is skipped. 38 | #' @importFrom testthat skip 39 | #' @return `NULL` or invoke an error produced by `testthat::skip` 40 | #' @note By default `TESTING_DEPTH` is equal to 3 if there is no environment variable for it. 41 | #' By default `depth` argument lower or equal to 3 will not be skipped because by default `TESTING_DEPTH` 42 | #' is equal to 3. To skip <= 3 depth tests then the environment variable has to be lower than 3 respectively. 43 | skip_if_too_deep <- function(depth) { # nolintr 44 | checkmate::assert_numeric(depth, len = 1, lower = 0, upper = 5) 45 | testing_depth <- get_testing_depth() # by default 3 if there are no env variable 46 | if (testing_depth < depth) { 47 | testthat::skip(paste("testing depth", testing_depth, "is below current testing specification", depth)) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tests/testthat/setup-logger.R: -------------------------------------------------------------------------------- 1 | logger::log_appender(function(...) NULL, namespace = "teal.modules.clinical") 2 | -------------------------------------------------------------------------------- /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/test-facet_grid_formula.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("facet_grid_formula works", { 2 | testthat::expect_equal(paste0(facet_grid_formula("SEX", NULL)), c("~", ".", "SEX")) 3 | testthat::expect_equal(paste0(facet_grid_formula("SEX", character(0))), c("~", ".", "SEX")) 4 | testthat::expect_equal(paste0(facet_grid_formula(NULL, "SEX")), c("~", "SEX", ".")) 5 | testthat::expect_equal(paste0(facet_grid_formula("ACTARM", "SEX")), c("~", "SEX", "ACTARM")) 6 | }) 7 | -------------------------------------------------------------------------------- /tests/testthat/test-string_ops.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("`as_num` as a wide interpretation of input to extract numerics.", { 2 | dta <- list( 3 | character = c("text10,20.5letter30.!", "!-.40$$-50e5[", NA), 4 | factor = factor(c("]+60e-6, 7.7%%8L", "%90sep.100\"1L", NA_character_)), 5 | numeric = c(1, -5e+2, NA), 6 | logical = c(TRUE, FALSE, NA) 7 | ) 8 | 9 | expected <- list( 10 | character = list(c(10, 20.5, 30), c(-.4, -50e5), NA), 11 | factor = list(c(60e-6, 7.7, 8), c(90, .1, 1), NA), 12 | numeric = c(1, -5e+2, NA), 13 | logical = c(1, 0, NA) 14 | ) 15 | 16 | test <- lapply(dta, as_num) 17 | test <- lapply( 18 | X = list(output = test, reference = expected), 19 | FUN = function(x) { 20 | y <- unlist(x) 21 | y <- y[!is.na(y)] 22 | y 23 | } 24 | ) 25 | 26 | testthat::expect_equal(test$output, test$reference) 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test-substitute_names.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("substitute_q works as expected", { 2 | result <- substitute_q( 3 | qexpr = quote(a <- c + d), 4 | env = list(c = 5, d = 3) 5 | ) 6 | expected <- quote(a <- 5 + 3) 7 | testthat::expect_identical(result, expected) 8 | }) 9 | 10 | testthat::test_that("substitute_q fails on unquoted call", { 11 | testthat::expect_error(substitute_q(c + d, env = list(c = 5, d = 3))) 12 | }) 13 | 14 | testthat::test_that("h_subst_lhs_names works as expected", { 15 | result <- h_subst_lhs_names( 16 | qexpr = quote(c(a = d, b = 3, z = "foo")), 17 | names = list(a = as.name("x"), z = as.name("y")) 18 | ) 19 | expected <- quote(c(x = d, b = 3, y = "foo")) 20 | testthat::expect_identical(result, expected) 21 | }) 22 | 23 | testthat::test_that("substitute_lhs_names works as expected with nested expressions", { 24 | result <- substitute_lhs_names( 25 | qexpr = quote(anl <- anl %>% mutate(a = factor(a))), 26 | names = list(a = as.name("AEBODSYS")) 27 | ) 28 | expected <- quote(anl <- anl %>% mutate(AEBODSYS = factor(a))) 29 | testthat::expect_identical(result, expected) 30 | }) 31 | 32 | testthat::test_that("substitute_lhs_names does not lead to infinite recursion", { 33 | result <- substitute_lhs_names( 34 | qexpr = quote(c(a = d, b = 3, z = "foo")), 35 | names = list(b = as.name("x"), z = as.name("y")) 36 | ) 37 | expected <- quote(c(a = d, x = 3, y = "foo")) 38 | testthat::expect_identical(result, expected) 39 | }) 40 | 41 | testthat::test_that("substitute_rhs works as expected", { 42 | result <- substitute_rhs( 43 | qexpr = quote(c(a = d, b = 3, z = "foo")), 44 | env = list(d = as.name("x"), z = as.name("y")) 45 | ) 46 | expected <- quote(c(a = x, b = 3, z = "foo")) 47 | testthat::expect_identical(result, expected) 48 | }) 49 | 50 | testthat::test_that("substitute_names works as expected", { 51 | result <- substitute_names( 52 | expr = c(a = d, b = 3, z = "foo"), 53 | names = list(d = as.name("x"), z = as.name("y")) 54 | ) 55 | expected <- quote(c(a = x, b = 3, y = "foo")) 56 | testthat::expect_identical(result, expected) 57 | }) 58 | 59 | testthat::test_that("substitute_names can also substitute other expressions if requested", { 60 | result <- substitute_names( 61 | expr = c(a = d, b = 3, z = doo), 62 | names = list(d = as.name("x"), z = as.name("y")), 63 | others = list(doo = "loo") 64 | ) 65 | expected <- quote(c(a = x, b = 3, y = "loo")) 66 | testthat::expect_identical(result, expected) 67 | }) 68 | 69 | testthat::test_that("substitute_names works as expected with nested expressions", { 70 | result <- substitute_names( 71 | expr = anl <- anl %>% mutate(a = factor(a)), 72 | names = list(a = as.name("AEBODSYS")) 73 | ) 74 | expected <- quote(anl <- anl %>% mutate(AEBODSYS = factor(AEBODSYS))) 75 | testthat::expect_identical(result, expected) 76 | }) 77 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_a_gee.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_a_gee t_gee_cov table works as expected with default input", { 2 | result <- template_a_gee( 3 | output_table = "t_gee_cov", 4 | aval_var = "AVAL", 5 | id_var = "USUBJID", 6 | arm_var = "ARMCD", 7 | visit_var = "AVISIT", 8 | split_covariates = c(), 9 | cor_struct = "unstructured" 10 | ) 11 | 12 | res <- testthat::expect_silent(result) 13 | testthat::expect_snapshot(res) 14 | }) 15 | 16 | testthat::test_that("template_a_gee t_gee_coef table works as expected with default input", { 17 | result <- template_a_gee( 18 | output_table = "t_gee_coef", 19 | aval_var = "AVAL", 20 | id_var = "USUBJID", 21 | arm_var = "ARMCD", 22 | visit_var = "AVISIT", 23 | split_covariates = c(), 24 | cor_struct = "unstructured" 25 | ) 26 | 27 | res <- testthat::expect_silent(result) 28 | testthat::expect_snapshot(res) 29 | }) 30 | 31 | testthat::test_that("template_a_gee works as expected with non-default reference arm", { 32 | result <- template_a_gee( 33 | output_table = "t_gee_lsmeans", 34 | aval_var = "AVAL", 35 | id_var = "USUBJID", 36 | arm_var = "ARMCD", 37 | ref_group = "B: Placebo", 38 | visit_var = "AVISIT", 39 | split_covariates = c(), 40 | cor_struct = "unstructured" 41 | ) 42 | 43 | res <- testthat::expect_silent(result) 44 | testthat::expect_snapshot(res) 45 | }) 46 | 47 | testthat::test_that("template_a_gee works as expected when arm is not considered in the model", { 48 | result <- template_a_gee( 49 | output_table = "t_gee_lsmeans", 50 | aval_var = "AVAL", 51 | id_var = "USUBJID", 52 | arm_var = NULL, 53 | ref_group = NULL, 54 | visit_var = "AVISIT", 55 | split_covariates = c(), 56 | cor_struct = "unstructured" 57 | ) 58 | 59 | res <- testthat::expect_silent(result) 60 | testthat::expect_snapshot(res) 61 | }) 62 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_a_mmrm.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_fit_mmrm works as expected when not combining comparison arms", { 2 | result <- template_fit_mmrm( 3 | parentname = "adsl", 4 | dataname = "adqs", 5 | aval_var = "AVAL", 6 | arm_var = "ARMCD", 7 | ref_arm = "ARM A", 8 | comp_arm = c("ARM B", "ARM C"), 9 | combine_comp_arms = FALSE, 10 | id_var = "USUBJID", 11 | visit_var = "AVISIT", 12 | cov_var = c() 13 | ) 14 | 15 | res <- testthat::expect_silent(result) 16 | testthat::expect_snapshot(res) 17 | }) 18 | 19 | testthat::test_that("template_fit_mmrm works as expected when combining combination arms", { 20 | result <- template_fit_mmrm( 21 | parentname = "adsl", 22 | dataname = "adqs", 23 | aval_var = "AVAL", 24 | arm_var = "ARMCD", 25 | ref_arm = "ARM A", 26 | comp_arm = c("ARM B", "ARM C"), 27 | combine_comp_arms = TRUE, 28 | id_var = "USUBJID", 29 | visit_var = "AVISIT", 30 | cov_var = c("SEX", "BASE", "AVISIT"), 31 | parallel = TRUE 32 | ) 33 | 34 | res <- testthat::expect_silent(result) 35 | testthat::expect_snapshot(res) 36 | }) 37 | 38 | testthat::test_that("template_mmrm_tables works as expected", { 39 | result <- template_mmrm_tables( 40 | parentname = "ADSL", 41 | dataname = "ANL", 42 | fit_name = "fit_mmrm", 43 | arm_var = "ARMCD", 44 | ref_arm = "ARM A", 45 | visit_var = "AVISIT", 46 | paramcd = "ALBUMIN", 47 | show_relative = "increase" 48 | ) 49 | 50 | res <- testthat::expect_silent(result) 51 | testthat::expect_snapshot(res) 52 | }) 53 | 54 | testthat::test_that("template_mmrm_tables works as expected when arm is not considered in the model", { 55 | result <- template_mmrm_tables( 56 | parentname = "ADSL", 57 | dataname = "ANL", 58 | fit_name = "fit_mmrm", 59 | arm_var = NULL, 60 | ref_arm = NULL, 61 | visit_var = "AVISIT", 62 | paramcd = "ALBUMIN", 63 | show_relative = NULL 64 | ) 65 | 66 | res <- testthat::expect_silent(result) 67 | testthat::expect_snapshot(res) 68 | }) 69 | 70 | testthat::test_that("template_mmrm_plots works as expected", { 71 | result <- template_mmrm_plots( 72 | "fit_mmrm", 73 | lsmeans_plot = list( 74 | select = c("estimates", "contrasts"), 75 | width = 0.6, 76 | show_pval = FALSE 77 | ), 78 | diagnostic_plot = list( 79 | type = "fit-residual", 80 | z_threshold = NULL 81 | ) 82 | ) 83 | 84 | res <- testthat::expect_silent(result) 85 | testthat::expect_snapshot(res) 86 | }) 87 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_g_ci.R: -------------------------------------------------------------------------------- 1 | # Test correspond to sections in the TLG catalog. 2 | testthat::test_that("1. and 2. Mean and 95% CIs for mean", { 3 | result <- template_g_ci( 4 | dataname = "adlb", 5 | x_var = "ARMCD", 6 | y_var = "AVAL", 7 | grp_var = "SEX", 8 | stat = "mean" 9 | ) 10 | 11 | res <- testthat::expect_silent(result) 12 | testthat::expect_snapshot(res) 13 | # Check the output. 14 | # eval(result) ; gg # nolint: commented_code. 15 | }) 16 | 17 | testthat::test_that("3. Confidence Interval Plot (using different stratification variable)", { 18 | result <- template_g_ci( 19 | dataname = "adlb", 20 | x_var = "ARMCD", 21 | y_var = "AVAL", 22 | grp_var = "STRATA2", 23 | stat = "mean" 24 | ) 25 | 26 | res <- testthat::expect_silent(result) 27 | testthat::expect_snapshot(res) 28 | # Check the output. 29 | # eval(result) ; gg # nolint: commented_code. 30 | }) 31 | 32 | testthat::test_that("4. Median and 95% CIs for median", { 33 | result <- template_g_ci( 34 | dataname = "adlb", 35 | x_var = "ARMCD", 36 | y_var = "AVAL", 37 | grp_var = "STRATA1", 38 | stat = "median" 39 | ) 40 | 41 | res <- testthat::expect_silent(result) 42 | testthat::expect_snapshot(res) 43 | # Check the output. 44 | # eval(result) ; gg # nolint: commented_code. 45 | }) 46 | 47 | testthat::test_that("5. Using different alpha level", { 48 | result <- template_g_ci( 49 | dataname = "adlb", 50 | x_var = "ARMCD", 51 | y_var = "AVAL", 52 | grp_var = "SEX", 53 | stat = "mean", 54 | conf_level = 0.90 55 | ) 56 | 57 | res <- testthat::expect_silent(result) 58 | testthat::expect_snapshot(res) 59 | # Check the output. 60 | # eval(result) ; gg # nolint: commented_code. 61 | }) 62 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_g_forest_rsp.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_forest_rsp generates correct expressions", { 2 | result <- template_forest_rsp( 3 | dataname = "adrs", 4 | parentname = "adsl", 5 | arm_var = "ARMCD", 6 | ref_arm = "ARM A", 7 | comp_arm = c("ARM B", "ARM C"), 8 | aval_var = "AVALC", 9 | responders = c("CR", "PR"), 10 | subgroup_var = c("SEX", "STRATA2"), 11 | strata_var = NULL, 12 | conf_level = 0.95 13 | ) 14 | 15 | res <- testthat::expect_silent(result) 16 | testthat::expect_snapshot(res) 17 | }) 18 | 19 | testthat::test_that("template_forest_rsp works with risk difference column added", { 20 | result <- template_forest_rsp( 21 | dataname = "adrs", 22 | parentname = "adsl", 23 | arm_var = "ARMCD", 24 | ref_arm = "ARM A", 25 | comp_arm = c("ARM B", "ARM C"), 26 | aval_var = "AVALC", 27 | responders = c("CR", "PR"), 28 | subgroup_var = c("SEX", "STRATA2"), 29 | strata_var = NULL, 30 | stats = c("n_tot", "or", "ci"), 31 | riskdiff = control_riskdiff(col_label = "Prop. Diff"), 32 | conf_level = 0.95 33 | ) 34 | 35 | res <- testthat::expect_silent(result) 36 | testthat::expect_snapshot(res) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_g_forest_tte.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_forest_tte generates correct expressions", { 2 | result <- template_forest_tte( 3 | dataname = "adtte", 4 | arm_var = "ARMCD", 5 | ref_arm = "ARM A", 6 | comp_arm = c("ARM B", "ARM C"), 7 | subgroup_var = c("SEX", "BMRKR2"), 8 | strata_var = "STRATA2", 9 | conf_level = 0.90, 10 | col_symbol_size = NULL 11 | ) 12 | 13 | res <- testthat::expect_silent(result) 14 | testthat::expect_snapshot(res) 15 | }) 16 | 17 | testthat::test_that("template_forest_tte works with risk difference column added", { 18 | result <- template_forest_tte( 19 | dataname = "adtte", 20 | arm_var = "ARMCD", 21 | ref_arm = "ARM A", 22 | comp_arm = c("ARM B", "ARM C"), 23 | subgroup_var = c("SEX", "BMRKR2"), 24 | strata_var = "STRATA2", 25 | stats = c("n_tot", "hr", "ci"), 26 | riskdiff = control_riskdiff(col_label = "Prop. Diff"), 27 | conf_level = 0.90, 28 | col_symbol_size = NULL 29 | ) 30 | 31 | res <- testthat::expect_silent(result) 32 | testthat::expect_snapshot(res) 33 | }) 34 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_g_ipp.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_g_ipp works as expected with default arguments", { 2 | result <- template_g_ipp( 3 | paramcd = "PARAMCD", arm_var = "ARMCD", 4 | arm_levels = letters[1:3], avalu_first = letters[4], paramcd_first = letters[5] 5 | ) 6 | 7 | res <- testthat::expect_silent(result) 8 | testthat::expect_snapshot(res) 9 | }) 10 | 11 | testthat::test_that("template_g_ipp works as expected with non-default arguments", { 12 | result <- template_g_ipp( 13 | dataname = "adlb", 14 | paramcd = "PARAM", 15 | arm_levels = letters[1:3], 16 | avalu_first = letters[4], 17 | paramcd_first = letters[5], 18 | aval_var = "AVAL", 19 | avalu_var = "AVALU", 20 | arm_var = "ARMCD", 21 | id_var = "SUBJID", 22 | visit_var = "AVISIT", 23 | baseline_var = "BASE", 24 | add_baseline_hline = TRUE, 25 | separate_by_obs = TRUE, 26 | add_avalu = TRUE 27 | ) 28 | 29 | res <- testthat::expect_silent(result) 30 | testthat::expect_snapshot(res) 31 | }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_g_km.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_g_km works as expected with default arguments", { 2 | result <- template_g_km(comp_arm = c("ARM A", "ARM B")) 3 | 4 | res <- testthat::expect_silent(result) 5 | testthat::expect_snapshot(res) 6 | }) 7 | 8 | testthat::test_that("template_g_km gives correct data expression when we want to compare versus reference arms", { 9 | result <- template_g_km( 10 | comp_arm = c("ARM A", "ARM B"), 11 | ref_arm = c("ARM C", "ARM D"), 12 | compare_arm = TRUE 13 | ) 14 | 15 | res <- testthat::expect_silent(result) 16 | testthat::expect_snapshot(res) 17 | }) 18 | 19 | testthat::test_that("template_g_km gives correct data expression when we want to combine comparison arms", { 20 | result <- template_g_km( 21 | comp_arm = c("ARM A", "ARM B"), 22 | ref_arm = c("ARM C", "ARM D"), 23 | compare_arm = TRUE, 24 | combine_comp_arms = TRUE 25 | ) 26 | 27 | res <- testthat::expect_silent(result) 28 | testthat::expect_snapshot(res) 29 | }) 30 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_g_lineplot.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_g_lineplot works as expected with default arguments", { 2 | result <- template_g_lineplot() 3 | 4 | res <- testthat::expect_silent(result) 5 | testthat::expect_snapshot(res) 6 | }) 7 | 8 | testthat::test_that("template_g_lineplot gives correct data expression with custom arguments", { 9 | result <- template_g_lineplot( 10 | group_var = "ARMCD", 11 | y = "CHG", 12 | mid = "median", 13 | interval = "median_ci", 14 | whiskers = "median_ci_upr", 15 | table = c("mean_sd", "median", "median_ci"), 16 | mid_type = "l", 17 | conf_level = 0.9, 18 | incl_screen = FALSE, 19 | title = "Line Plot" 20 | ) 21 | 22 | res <- testthat::expect_silent(result) 23 | testthat::expect_snapshot(res) 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_abnormality.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_abnormality generates correct expressions with default arguments", { 2 | result <- template_abnormality( 3 | dataname = "adlb", 4 | parentname = "adsl", 5 | arm_var = "ARM", 6 | id_var = "USUBJID", 7 | by_vars = c("AVISIT", "PARAM"), 8 | abnormal = list(low = c("LOW", "LOW LOW"), high = c("HIGH", "HIGH HIGH")), 9 | grade = "ANRIND", 10 | add_total = FALSE, 11 | exclude_base_abn = FALSE, 12 | drop_arm_levels = TRUE, 13 | tbl_title = "my_title" 14 | ) 15 | 16 | res <- testthat::expect_silent(result) 17 | testthat::expect_snapshot(res) 18 | }) 19 | 20 | testthat::test_that("template_abnormality generates correct expressions with custom arguments", { 21 | result <- template_abnormality( 22 | dataname = "adlb", 23 | parentname = "adsl", 24 | arm_var = "ARM", 25 | id_var = "USUBJID", 26 | by_vars = c("AVISIT", "PARAMCD"), 27 | abnormal = list(Low = "LOW", Medium = "MEDIUM"), 28 | grade = "MYANRIND", 29 | baseline_var = "MYBASELINE", 30 | treatment_flag_var = "MYTRTFL", 31 | treatment_flag = "YES", 32 | add_total = TRUE, 33 | exclude_base_abn = TRUE, 34 | drop_arm_levels = FALSE, 35 | tbl_title = "my_title" 36 | ) 37 | 38 | res <- testthat::expect_silent(result) 39 | testthat::expect_snapshot(res) 40 | }) 41 | 42 | testthat::test_that("template_abnormality generates correct expressions with customized na_level", { 43 | result <- template_abnormality( 44 | dataname = "adlb", 45 | parentname = "adsl", 46 | arm_var = "ARM", 47 | id_var = "USUBJID", 48 | by_vars = c("AVISIT", "PARAM"), 49 | abnormal = list(low = c("LOW", "LOW LOW"), high = c("HIGH", "HIGH HIGH")), 50 | grade = "ANRIND", 51 | add_total = FALSE, 52 | exclude_base_abn = FALSE, 53 | drop_arm_levels = TRUE, 54 | na_level = "NA", 55 | tbl_title = "my_title" 56 | ) 57 | 58 | res <- testthat::expect_silent(result) 59 | testthat::expect_snapshot(res) 60 | }) 61 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_abnormality_by_worst_grade.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_abnormality_by_worst_grade generates correct expressions with default arguments", { 2 | result <- template_abnormality_by_worst_grade( 3 | parentname = "adsl", 4 | dataname = "adlb", 5 | arm_var = "ARMCD", 6 | id_var = "USUBJID", 7 | paramcd = "PARAMCD", 8 | atoxgr_var = "ATOXGR", 9 | worst_high_flag_var = "WGRHIFL", 10 | worst_low_flag_var = "WGRLOFL", 11 | worst_flag_indicator = "Y", 12 | add_total = FALSE, 13 | drop_arm_levels = TRUE 14 | ) 15 | 16 | res <- testthat::expect_silent(result) 17 | testthat::expect_snapshot(res) 18 | }) 19 | 20 | testthat::test_that("template_abnormality_by_worst_grade generates correct expressions with custom arguments", { 21 | result <- template_abnormality_by_worst_grade( 22 | parentname = "myadsl", 23 | dataname = "myadlb", 24 | arm_var = "ARMCD", 25 | id_var = "USUBJID", 26 | paramcd = "myPARAMCD", 27 | atoxgr_var = "ATOXGR", 28 | worst_high_flag_var = "WGRHIFL", 29 | worst_low_flag_var = "WGRLOFL", 30 | worst_flag_indicator = "Y", 31 | add_total = FALSE, 32 | drop_arm_levels = TRUE 33 | ) 34 | 35 | res <- testthat::expect_silent(result) 36 | testthat::expect_snapshot(res) 37 | }) 38 | 39 | testthat::test_that("template_abnormality_by_worst_grade throws an error when ATOXGR contains NA values", { 40 | adsl <- tmc_ex_adsl 41 | adlb <- tmc_ex_adlb 42 | adlb$ATOXGR[1:100] <- NA 43 | 44 | template <- template_abnormality_by_worst_grade( 45 | parentname = "adsl", 46 | dataname = "adlb", 47 | arm_var = "ARMCD", 48 | id_var = "USUBJID", 49 | paramcd = "PARAMCD", 50 | atoxgr_var = "ATOXGR", 51 | worst_high_flag_var = "WGRHIFL", 52 | worst_low_flag_var = "WGRLOFL", 53 | worst_flag_indicator = "Y", 54 | add_total = FALSE, 55 | drop_arm_levels = TRUE 56 | ) 57 | 58 | testthat::expect_error(mapply(eval, template)) 59 | }) 60 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_coxreg.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_coxreg generates correct univariate cox regression expressions", { 2 | result <- template_coxreg_u( 3 | dataname = "adrs", 4 | cov_var = NULL, 5 | arm_var = "ARMCD", 6 | cnsr_var = "CNSR", 7 | aval_var = "AVAL", 8 | ref_arm = "ARM A", 9 | comp_arm = c("ARM B", "ARM C"), 10 | paramcd = "OS", 11 | at = list(AGE = c(35, 45)), 12 | strata_var = "STRATA1", 13 | combine_comp_arms = FALSE, 14 | control = control_coxreg( 15 | pval_method = "wald", 16 | ties = "efron" 17 | ) 18 | ) 19 | 20 | res <- testthat::expect_silent(result) 21 | testthat::expect_snapshot(res) 22 | }) 23 | 24 | testthat::test_that("template_coxreg generates correct univariate cox regression expressions with interactions", { 25 | result <- template_coxreg_u( 26 | dataname = "adrs", 27 | cov_var = NULL, 28 | arm_var = "ARMCD", 29 | cnsr_var = "CNSR", 30 | aval_var = "AVAL", 31 | ref_arm = "ARM A", 32 | comp_arm = c("ARM B", "ARM C"), 33 | paramcd = "OS", 34 | at = list(AGE = c(35, 45)), 35 | strata_var = "STRATA1", 36 | combine_comp_arms = FALSE, 37 | control = control_coxreg( 38 | pval_method = "wald", 39 | ties = "efron", 40 | interaction = TRUE 41 | ) 42 | ) 43 | 44 | res <- testthat::expect_silent(result) 45 | testthat::expect_snapshot(res) 46 | }) 47 | 48 | testthat::test_that("template_coxreg generates correct multivariate cox regression expressions", { 49 | result <- template_coxreg_m( 50 | dataname = "adrs", 51 | cov_var = c("AGE", "SEX"), 52 | arm_var = "ARM", 53 | cnsr_var = "CNSR", 54 | aval_var = "AVAL", 55 | ref_arm = "A: Drug X", 56 | comp_arm = c("B: Placebo", "C: Combination"), 57 | paramcd = "OS", 58 | combine_comp_arms = TRUE, 59 | control = control_coxreg() 60 | ) 61 | 62 | res <- testthat::expect_silent(result) 63 | testthat::expect_snapshot(res) 64 | }) 65 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_events.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_events generates correct expressions", { 2 | result <- template_events( 3 | dataname = "adae", 4 | parentname = "adsl", 5 | arm_var = "ACTARM", 6 | hlt = "AEBODSYS", 7 | llt = "AEDECOD", 8 | label_hlt = "Body System", 9 | label_llt = "Adverse Event Code", 10 | add_total = TRUE, 11 | drop_arm_levels = TRUE 12 | ) 13 | 14 | res <- testthat::expect_silent(result) 15 | testthat::expect_snapshot(res) 16 | }) 17 | 18 | testthat::test_that("template_events generates correct expressions for nested columns", { 19 | result <- template_events( 20 | dataname = "adae", 21 | parentname = "adsl", 22 | arm_var = c("ACTARM", "ACTARMCD"), 23 | hlt = "AEBODSYS", 24 | llt = "AEDECOD", 25 | label_hlt = "Body System", 26 | label_llt = "Adverse Event Code", 27 | add_total = TRUE, 28 | drop_arm_levels = TRUE 29 | ) 30 | 31 | res <- testthat::expect_silent(result) 32 | testthat::expect_snapshot(res) 33 | }) 34 | 35 | testthat::test_that("template_events can generate customized table", { 36 | result <- template_events( 37 | dataname = "adcm", 38 | parentname = "adsl", 39 | arm_var = "ACTARM", 40 | hlt = NULL, 41 | llt = "CMDECOD", 42 | label_hlt = NULL, 43 | label_llt = "Con Med Code", 44 | add_total = FALSE, 45 | event_type = "treatment", 46 | drop_arm_levels = FALSE 47 | ) 48 | 49 | res <- testthat::expect_silent(result) 50 | testthat::expect_snapshot(res) 51 | }) 52 | 53 | testthat::test_that("template_events can generate customized table with alphabetical sorting", { 54 | result <- template_events( 55 | dataname = "adae", 56 | parentname = "adsl", 57 | arm_var = "ACTARM", 58 | hlt = "AEBODSYS", 59 | llt = "AEDECOD", 60 | label_hlt = "Body System", 61 | label_llt = "Adverse Event Code", 62 | add_total = TRUE, 63 | event_type = "event", 64 | sort_criteria = "alpha", 65 | drop_arm_levels = TRUE 66 | ) 67 | 68 | res <- testthat::expect_silent(result) 69 | testthat::expect_snapshot(res) 70 | }) 71 | 72 | testthat::test_that("template_events can generate customized table with pruning", { 73 | result <- template_events( 74 | dataname = "adae", 75 | parentname = "adsl", 76 | arm_var = "ACTARM", 77 | hlt = "AEBODSYS", 78 | llt = "AEDECOD", 79 | label_hlt = "Body System", 80 | label_llt = "Adverse Event Code", 81 | add_total = TRUE, 82 | event_type = "event", 83 | prune_freq = 0.4, 84 | prune_diff = 0.1, 85 | drop_arm_levels = TRUE 86 | ) 87 | 88 | res <- testthat::expect_silent(result) 89 | testthat::expect_snapshot(res) 90 | }) 91 | 92 | testthat::test_that("template_events can generate customized table with pruning for nested column", { 93 | result <- template_events( 94 | dataname = "adae", 95 | parentname = "adsl", 96 | arm_var = c("ACTARM", "ACTARMCD"), 97 | hlt = "AEBODSYS", 98 | llt = "AEDECOD", 99 | label_hlt = "Body System", 100 | label_llt = "Adverse Event Code", 101 | add_total = TRUE, 102 | event_type = "event", 103 | prune_freq = 0.4, 104 | prune_diff = 0.1, 105 | drop_arm_levels = TRUE 106 | ) 107 | 108 | res <- testthat::expect_silent(result) 109 | testthat::expect_snapshot(res) 110 | }) 111 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_events_patyear.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_events_patyear generates standard expressions", { 2 | result <- template_events_patyear( 3 | dataname = "adaette", 4 | parentname = "adsl", 5 | arm_var = "ARMCD", 6 | events_var = "n_events", 7 | label_paramcd = "Time to first occurrence of any adverse event", 8 | aval_var = "AVAL", 9 | add_total = TRUE, 10 | drop_arm_levels = TRUE, 11 | control = control_incidence_rate() 12 | ) 13 | 14 | res <- testthat::expect_silent(result) 15 | testthat::expect_snapshot(res) 16 | }) 17 | 18 | testthat::test_that("template_events_patyear generates right expressions with non-default", { 19 | result <- template_events_patyear( 20 | dataname = "adaette", 21 | parentname = "adsl", 22 | arm_var = "ARM", 23 | events_var = "n_events", 24 | label_paramcd = "Time to first occurrence of any adverse event", 25 | aval_var = "AVAL", 26 | add_total = FALSE, 27 | drop_arm_levels = FALSE, 28 | control = control_incidence_rate() 29 | ) 30 | 31 | res <- testthat::expect_silent(result) 32 | testthat::expect_snapshot(res) 33 | }) 34 | 35 | testthat::test_that("template_events_patyear generates right expressions with non-default controls", { 36 | result <- template_events_patyear( 37 | dataname = "adaette", 38 | parentname = "adsl", 39 | arm_var = c("ARM", "SEX"), 40 | aval_var = "AVAL", 41 | events_var = "n_events", 42 | label_paramcd = "Time to first occurrence of any adverse event", 43 | add_total = TRUE, 44 | drop_arm_levels = TRUE, 45 | control = control_incidence_rate( 46 | conf_level = 0.9, 47 | conf_type = "exact", 48 | input_time_unit = "month", 49 | num_pt_year = 80 50 | ) 51 | ) 52 | 53 | res <- testthat::expect_silent(result) 54 | testthat::expect_snapshot(res) 55 | }) 56 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_events_summary.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_events_summary generates minimal table", { 2 | result <- template_events_summary( 3 | anl_name = "adae", 4 | parentname = "adsl", 5 | arm_var = "ARM" 6 | ) 7 | 8 | res <- testthat::expect_silent(result) 9 | testthat::expect_snapshot(res) 10 | }) 11 | 12 | testthat::test_that("template_events_summary generates table with multiple flags", { 13 | result <- template_events_summary( 14 | anl_name = "adae", 15 | parentname = "adsl", 16 | arm_var = "ARM", 17 | add_total = TRUE, 18 | flag_var_anl = c("A", "B", "C"), 19 | flag_var_aesi = c("X", "Y"), 20 | count_dth = FALSE, 21 | count_wd = FALSE, 22 | count_subj = TRUE, 23 | count_pt = TRUE, 24 | count_events = TRUE 25 | ) 26 | 27 | res <- testthat::expect_silent(result) 28 | testthat::expect_snapshot(res) 29 | }) 30 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_exposure.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_exposure generates correct expressions with default arguments", { 2 | result <- template_exposure( 3 | parentname = "adsl", 4 | dataname = "adex", 5 | paramcd = "TDURD", 6 | id_var = "USUBJID", 7 | row_by_var = "RACE", 8 | col_by_var = "SEX", 9 | add_total = FALSE, 10 | drop_levels = TRUE, 11 | na_level = "<Missing>", 12 | aval_var = "AVAL", 13 | avalu_var = "Days" 14 | ) 15 | 16 | res <- testthat::expect_silent(result) 17 | testthat::expect_snapshot(res) 18 | }) 19 | 20 | testthat::test_that("template_exposure generates correct expressions with custom arguments", { 21 | result <- template_exposure( 22 | parentname = "myadsl", 23 | dataname = "myadex", 24 | paramcd = "myTDURD", 25 | id_var = "USUBJID", 26 | row_by_var = "myRACE", 27 | col_by_var = "SEX", 28 | add_total = FALSE, 29 | drop_levels = TRUE, 30 | na_level = "<myMissing>", 31 | aval_var = "myAVAL", 32 | avalu_var = "Days" 33 | ) 34 | 35 | res <- testthat::expect_silent(result) 36 | testthat::expect_snapshot(res) 37 | }) 38 | 39 | testthat::test_that("template_exposure generates correct expressions with paramcd_label", { 40 | result <- template_exposure( 41 | parentname = "adsl", 42 | dataname = "adex", 43 | paramcd = "TDURD", 44 | paramcd_label = "Total Duration (Days)", 45 | id_var = "USUBJID", 46 | row_by_var = "RACE", 47 | col_by_var = "SEX", 48 | add_total = FALSE, 49 | drop_levels = TRUE, 50 | na_level = "<Missing>", 51 | aval_var = "AVAL", 52 | avalu_var = "Days" 53 | ) 54 | 55 | res <- testthat::expect_silent(result) 56 | testthat::expect_snapshot(res) 57 | }) 58 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_logisitic.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_logistic generates correct expressions", { 2 | result <- template_logistic( 3 | dataname = "ANL", 4 | arm_var = "ARMCD", 5 | aval_var = "AVALC", 6 | label_paramcd = "Best Confirmed Overall Response by Investigator", 7 | cov_var = c("AGE", "SEX"), 8 | interaction_var = "AGE", 9 | ref_arm = c("ARM A", "ARM B"), 10 | comp_arm = "ARM C", 11 | conf_level = 0.95, 12 | combine_comp_arms = FALSE, 13 | responder_val = c("CR"), 14 | topleft = "BESRSPI", 15 | at = c(30, 40) 16 | ) 17 | 18 | res <- testthat::expect_silent(result) 19 | testthat::expect_snapshot(res) 20 | }) 21 | 22 | testthat::test_that("template_logistic generates correct expressions for no arm variable", { 23 | result <- template_logistic( 24 | dataname = "ANL", 25 | arm_var = NULL, 26 | aval_var = "AVALC", 27 | label_paramcd = "Best Confirmed Overall Response by Investigator", 28 | cov_var = c("AGE", "SEX"), 29 | interaction_var = "AGE", 30 | conf_level = 0.95, 31 | combine_comp_arms = FALSE, 32 | responder_val = c("CR"), 33 | topleft = "BESRSPI", 34 | at = c(30, 40) 35 | ) 36 | 37 | res <- testthat::expect_silent(result) 38 | testthat::expect_snapshot(res) 39 | }) 40 | 41 | testthat::test_that("template_logistic generates correct expressions", { 42 | result <- template_logistic( 43 | dataname = "ANL", 44 | arm_var = "ARMCD", 45 | aval_var = "AVALC", 46 | label_paramcd = "Best Confirmed Overall Response by Investigator", 47 | cov_var = c("AGE", "SEX"), 48 | interaction_var = "AGE", 49 | ref_arm = c("ARM A", "ARM B"), 50 | comp_arm = "ARM C", 51 | conf_level = 0.95, 52 | combine_comp_arms = FALSE, 53 | responder_val = c("CR"), 54 | topleft = "BESRSPI", 55 | at = c(30, 40) 56 | ) 57 | 58 | res <- testthat::expect_silent(result) 59 | testthat::expect_snapshot(res) 60 | }) 61 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_mult_events.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_mult_events generates correct expressions with 1 HLT parameter", { 2 | result <- template_mult_events( 3 | dataname = "adcm", 4 | parentname = "adsl", 5 | arm_var = "ARM", 6 | seq_var = "ASEQ", 7 | hlt = "ATC1", 8 | llt = "CMDECOD", 9 | add_total = TRUE, 10 | event_type = "treatment", 11 | drop_arm_levels = TRUE 12 | ) 13 | 14 | res <- testthat::expect_silent(result) 15 | testthat::expect_snapshot(res) 16 | }) 17 | 18 | testthat::test_that( 19 | "template_mult_events generates correct expressions with 2 HLT parameters and drop_arm_levels = FALSE", 20 | { 21 | result <- template_mult_events( 22 | dataname = "adcm", 23 | parentname = "adsl", 24 | arm_var = "ARM", 25 | seq_var = "ASEQ", 26 | hlt = c("ATC1", "ATC2"), 27 | llt = "CMDECOD", 28 | add_total = TRUE, 29 | event_type = "treatment", 30 | drop_arm_levels = FALSE 31 | ) 32 | 33 | res <- testthat::expect_silent(result) 34 | testthat::expect_snapshot(res) 35 | } 36 | ) 37 | 38 | testthat::test_that("template_mult_events generates correct expressions with 3 HLT parameters", { 39 | result <- template_mult_events( 40 | dataname = "adcm", 41 | parentname = "adsl", 42 | arm_var = "ARM", 43 | seq_var = "ASEQ", 44 | hlt = c("ATC1", "ATC2", "ATC3"), 45 | llt = "CMDECOD", 46 | add_total = TRUE, 47 | event_type = "treatment", 48 | drop_arm_levels = TRUE 49 | ) 50 | 51 | res <- testthat::expect_silent(result) 52 | testthat::expect_snapshot(res) 53 | }) 54 | 55 | testthat::test_that("template_mult_events generates correct expressions with 4 HLT parameters", { 56 | result <- template_mult_events( 57 | dataname = "adcm", 58 | parentname = "adsl", 59 | arm_var = "ARM", 60 | seq_var = "ASEQ", 61 | hlt = c("ATC1", "ATC2", "ATC3", "ATC4"), 62 | llt = "CMDECOD", 63 | add_total = TRUE, 64 | event_type = "treatment", 65 | drop_arm_levels = TRUE 66 | ) 67 | 68 | res <- testthat::expect_silent(result) 69 | testthat::expect_snapshot(res) 70 | }) 71 | 72 | testthat::test_that("template_mult_events generates correct expressions with no HLT parameters", { 73 | result <- template_mult_events( 74 | dataname = "adcm", 75 | parentname = "adsl", 76 | arm_var = "ARM", 77 | seq_var = "ASEQ", 78 | hlt = NULL, 79 | llt = "CMDECOD", 80 | add_total = TRUE, 81 | event_type = "treatment", 82 | drop_arm_levels = TRUE 83 | ) 84 | 85 | res <- testthat::expect_silent(result) 86 | testthat::expect_snapshot(res) 87 | }) 88 | 89 | testthat::test_that( 90 | "template_mult_events generates correct expressions with 1 HLT parameter and without 'All Patients' column", 91 | { 92 | result <- template_mult_events( 93 | dataname = "adcm", 94 | parentname = "adsl", 95 | arm_var = "ARM", 96 | seq_var = "ASEQ", 97 | hlt = "ATC1", 98 | llt = "CMDECOD", 99 | add_total = FALSE, 100 | event_type = "treatment", 101 | drop_arm_levels = TRUE 102 | ) 103 | 104 | res <- testthat::expect_silent(result) 105 | testthat::expect_snapshot(res) 106 | } 107 | ) 108 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_pp_medical_history.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_medical_history outputs a list with one named element", { 2 | testthat::expect_silent(res <- template_medical_history("ANL", "mhterm", "mhbodsys", "mhdistat")) 3 | testthat::expect_true(is.list(res)) 4 | testthat::expect_length(res, 1) 5 | testthat::expect_false(is.null(names(res))) 6 | }) 7 | 8 | testthat::test_that("template_medical_history's output has element table, which is of class call", { 9 | testthat::expect_silent(res <- template_medical_history("ANL", "mhterm", "mhbodsys", "mhdistat")) 10 | testthat::expect_true(is.call(res$table)) 11 | }) 12 | 13 | testthat::test_that("template_medical_history - non-default parameters", { 14 | testthat::expect_silent(res <- template_medical_history("anl", "mhterm", "mhbodsys", "mhdistat")) 15 | 16 | res <- testthat::expect_silent(res$table) 17 | testthat::expect_snapshot(res) 18 | }) 19 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_shift_by_arm.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_shift_by_arm generates correct expressions with default arguments", { 2 | result <- template_shift_by_arm( 3 | parentname = "adsl", 4 | dataname = "adeg", 5 | arm_var = "ARM", 6 | paramcd = "PARAMCD", 7 | visit_var = "AVISIT", 8 | aval_var = "ANRIND", 9 | baseline_var = "BNRIND", 10 | na_level = "<Missing>" 11 | ) 12 | 13 | res <- testthat::expect_silent(result) 14 | testthat::expect_snapshot(res) 15 | }) 16 | 17 | testthat::test_that("template_shift_by_arm generates correct expressions with add_total being TRUE", { 18 | result <- template_shift_by_arm( 19 | parentname = "adsl", 20 | dataname = "adeg", 21 | arm_var = "ARM", 22 | paramcd = "PARAMCD", 23 | visit_var = "AVISIT", 24 | aval_var = "ANRIND", 25 | baseline_var = "BNRIND", 26 | na_level = "<Missing>", 27 | add_total = TRUE 28 | ) 29 | 30 | res <- testthat::expect_silent(result) 31 | testthat::expect_snapshot(res) 32 | }) 33 | 34 | testthat::test_that("template_shift_by_arm generates correct expressions with na.rm being TRUE", { 35 | result <- template_shift_by_arm( 36 | parentname = "adsl", 37 | dataname = "adeg", 38 | arm_var = "ARM", 39 | paramcd = "PARAMCD", 40 | visit_var = "AVISIT", 41 | aval_var = "ANRIND", 42 | baseline_var = "BNRIND", 43 | na.rm = TRUE, 44 | na_level = "<Missing>" 45 | ) 46 | 47 | res <- testthat::expect_silent(result) 48 | testthat::expect_snapshot(res) 49 | }) 50 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_shift_by_arm_by_worst.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_shift_by_arm generates correct expressions with default arguments", { 2 | result <- template_shift_by_arm_by_worst( 3 | parentname = "adsl", 4 | dataname = "adeg", 5 | arm_var = "ARM", 6 | paramcd = "PARAMCD", 7 | aval_var = "AVALC", 8 | baseline_var = "BASEC", 9 | worst_flag_var = "WORS02FL", 10 | worst_flag = "Y", 11 | na_level = "<Missing>" 12 | ) 13 | 14 | res <- testthat::expect_silent(result) 15 | testthat::expect_snapshot(res) 16 | }) 17 | 18 | testthat::test_that("template_shift_by_arm generates correct expressions with add_total being TRUE", { 19 | result <- template_shift_by_arm_by_worst( 20 | parentname = "adsl", 21 | dataname = "adeg", 22 | arm_var = "ARM", 23 | paramcd = "PARAMCD", 24 | aval_var = "AVALC", 25 | baseline_var = "BASEC", 26 | worst_flag_var = "WORS02FL", 27 | worst_flag = "Y", 28 | na_level = "<Missing>", 29 | add_total = TRUE 30 | ) 31 | 32 | res <- testthat::expect_silent(result) 33 | testthat::expect_snapshot(res) 34 | }) 35 | 36 | testthat::test_that("template_shift_by_arm generates correct expressions with na.rm being TRUE", { 37 | result <- template_shift_by_arm_by_worst( 38 | parentname = "adsl", 39 | dataname = "adeg", 40 | arm_var = "ARM", 41 | paramcd = "PARAMCD", 42 | aval_var = "AVALC", 43 | baseline_var = "BASEC", 44 | worst_flag_var = "WORS02FL", 45 | worst_flag = "Y", 46 | na.rm = TRUE, 47 | na_level = "<Missing>" 48 | ) 49 | 50 | res <- testthat::expect_silent(result) 51 | testthat::expect_snapshot(res) 52 | }) 53 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_shift_by_grade.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_shift_by_grade generates correct expressions with default arguments", { 2 | result <- template_shift_by_grade( 3 | parentname = "adsl", 4 | dataname = "adlb", 5 | arm_var = "ARM", 6 | id_var = "USUBJID", 7 | visit_var = "AVISIT", 8 | worst_flag_var = c("WGRLOVFL"), 9 | worst_flag_indicator = "Y", 10 | anl_toxgrade_var = "ATOXGR", 11 | base_toxgrade_var = "BTOXGR", 12 | paramcd = "PARAMCD", 13 | drop_arm_levels = TRUE, 14 | add_total = FALSE, 15 | na_level = "<Missing>", 16 | code_missing_baseline = FALSE 17 | ) 18 | 19 | res <- testthat::expect_silent(result) 20 | testthat::expect_snapshot(res) 21 | }) 22 | 23 | testthat::test_that("template_shift_by_grade generates correct expressions with custom arguments", { 24 | result <- template_shift_by_grade( 25 | parentname = "adsl", 26 | dataname = "adlb", 27 | arm_var = "ARM", 28 | id_var = "MYUSUBJID", 29 | visit_var = "AVISIT", 30 | worst_flag_var = c("WGRLOVFL"), 31 | worst_flag_indicator = "YY", 32 | anl_toxgrade_var = "MYATOXGR", 33 | base_toxgrade_var = "MYBTOXGR", 34 | paramcd = "PARAMCD", 35 | drop_arm_levels = TRUE, 36 | add_total = FALSE, 37 | na_level = "<MYMissing>", 38 | code_missing_baseline = FALSE 39 | ) 40 | 41 | res <- testthat::expect_silent(result) 42 | testthat::expect_snapshot(res) 43 | }) 44 | 45 | testthat::test_that( 46 | "template_shift_by_grade throws an error when worst_flag_var is not one of WGRLOVFL, WGRLOFL, WGRHIVFL, WGRHIFL", 47 | { 48 | testthat::expect_error( 49 | result <- template_shift_by_grade( 50 | parentname = "adsl", 51 | dataname = "adlb", 52 | arm_var = "ARM", 53 | id_var = "USUBJID", 54 | visit_var = "AVISIT", 55 | worst_flag_var = c("another_value"), 56 | worst_flag_indicator = "Y", 57 | anl_toxgrade_var = "ATOXGR", 58 | base_toxgrade_var = "BTOXGR", 59 | paramcd = "PARAMCD", 60 | drop_arm_levels = TRUE, 61 | add_total = FALSE, 62 | na_level = "<Missing>", 63 | code_missing_baseline = FALSE 64 | ) 65 | ) 66 | } 67 | ) 68 | 69 | testthat::test_that( 70 | "template_shift_by_grade keeps the same number of missing data ('<Missing>') after preprocessing", 71 | { 72 | adsl <- tmc_ex_adsl 73 | adlb <- tmc_ex_adlb %>% dplyr::filter(WGRLOVFL == "Y") 74 | adlb$ATOXGR[1] <- NA 75 | adlb <- df_explicit_na(adlb) 76 | expected_missing_n <- sum(adlb$ATOXGR == "<Missing>") 77 | template <- template_shift_by_grade( 78 | parentname = "adsl", 79 | dataname = "adlb", 80 | arm_var = "ARM", 81 | id_var = "USUBJID", 82 | visit_var = "AVISIT", 83 | worst_flag_var = c(c("WGRLOVFL")), 84 | worst_flag_indicator = "Y", 85 | anl_toxgrade_var = "ATOXGR", 86 | base_toxgrade_var = "BTOXGR", 87 | paramcd = "PARAMCD", 88 | drop_arm_levels = TRUE, 89 | add_total = FALSE, 90 | na_level = "<Missing>", 91 | code_missing_baseline = FALSE 92 | ) 93 | 94 | template_data <- template$data 95 | data <- eval(template_data) 96 | result_missing_n <- sum(data$ATOXGR_GP == "Missing") 97 | 98 | testthat::expect_equal(expected_missing_n, result_missing_n) 99 | } 100 | ) 101 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_smq.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_smq generates correct expressions with default arguments", { 2 | result <- template_smq( 3 | parentname = "adsl", 4 | dataname = "adae", 5 | arm_var = c("ARMCD", "SEX"), 6 | id_var = "USUBJID", 7 | llt = "AEDECOD", 8 | add_total = FALSE, 9 | drop_arm_levels = FALSE, 10 | na_level = "<Missing>", 11 | smq_varlabel = "Standardized MedDRA Query", 12 | baskets = c("SMQ01NAM", "SMQ02NAM", "CQ01NAM"), 13 | sort_criteria = c("freq_desc") 14 | ) 15 | 16 | res <- testthat::expect_silent(result) 17 | testthat::expect_snapshot(res) 18 | }) 19 | 20 | testthat::test_that("template_smq generates correct expressions with custom arguments", { 21 | result <- template_smq( 22 | parentname = "myadsl", 23 | dataname = "myadae", 24 | arm_var = "myARMCD", 25 | id_var = "myUSUBJID", 26 | llt = "myAEDECOD", 27 | add_total = FALSE, 28 | drop_arm_levels = FALSE, 29 | na_level = "<Missing>", 30 | smq_varlabel = "mylabel", 31 | baskets = c("mybaskets"), 32 | sort_criteria = c("freq_desc") 33 | ) 34 | 35 | res <- testthat::expect_silent(result) 36 | testthat::expect_snapshot(res) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_summary.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_summary generates correct expressions", { 2 | result <- template_summary( 3 | dataname = "adrs", 4 | parentname = "adsl", 5 | arm_var = "ARM", 6 | sum_vars = c("RACE", "COUNTRY", "AGE"), 7 | add_total = FALSE, 8 | var_labels = character(), 9 | na.rm = FALSE, 10 | denominator = "N", 11 | drop_arm_levels = TRUE 12 | ) 13 | 14 | res <- testthat::expect_silent(result) 15 | testthat::expect_snapshot(res) 16 | }) 17 | 18 | testthat::test_that("template_summary can generate customized table", { 19 | result <- template_summary( 20 | dataname = "adrs", 21 | parentname = "adsl", 22 | arm_var = "ARMCD", 23 | sum_vars = "RACE", 24 | add_total = TRUE, 25 | var_labels = c(RACE = "Race"), 26 | na.rm = TRUE, 27 | denominator = "omit", 28 | drop_arm_levels = FALSE 29 | ) 30 | 31 | res <- testthat::expect_silent(result) 32 | testthat::expect_snapshot(res) 33 | }) 34 | 35 | testthat::test_that("template_summary generates correct expressions for multiple grouping variables", { 36 | result <- template_summary( 37 | dataname = "adrs", 38 | parentname = "adsl", 39 | arm_var = c("ARM", "STRATA1"), 40 | sum_vars = c("RACE", "COUNTRY", "AGE"), 41 | add_total = FALSE, 42 | var_labels = character(), 43 | na.rm = FALSE, 44 | denominator = "N", 45 | drop_arm_levels = TRUE 46 | ) 47 | 48 | res <- testthat::expect_silent(result) 49 | testthat::expect_snapshot(res) 50 | }) 51 | 52 | testthat::test_that( 53 | "template_summary generates correct expressions for multiple grouping variables and all patients", 54 | { 55 | result <- template_summary( 56 | dataname = "adrs", 57 | parentname = "adsl", 58 | arm_var = c("ARM", "STRATA1"), 59 | sum_vars = c("RACE", "COUNTRY", "AGE"), 60 | add_total = TRUE, 61 | var_labels = character(), 62 | na.rm = FALSE, 63 | denominator = "N", 64 | drop_arm_levels = TRUE 65 | ) 66 | 67 | res <- testthat::expect_silent(result) 68 | testthat::expect_snapshot(res) 69 | } 70 | ) 71 | 72 | testthat::test_that("template_summary generates correct expressions for customized numeric statistics", { 73 | result <- template_summary( 74 | dataname = "adrs", 75 | parentname = "adsl", 76 | arm_var = c("ARM", "STRATA1"), 77 | sum_vars = c("RACE", "COUNTRY", "AGE"), 78 | add_total = FALSE, 79 | var_labels = character(), 80 | na.rm = FALSE, 81 | numeric_stats = c("n"), 82 | denominator = "N", 83 | drop_arm_levels = TRUE 84 | ) 85 | 86 | res <- testthat::expect_silent(result) 87 | testthat::expect_snapshot(res) 88 | }) 89 | 90 | testthat::test_that("template_summary generates correct expressions when arm variable labels are added", { 91 | result <- template_summary( 92 | dataname = "adrs", 93 | parentname = "adsl", 94 | arm_var = c("ARM", "SEX"), 95 | sum_vars = c("RACE", "COUNTRY", "AGE"), 96 | arm_var_labels = c("Arm", "Sex") 97 | ) 98 | 99 | res <- testthat::expect_silent(result) 100 | testthat::expect_snapshot(res) 101 | }) 102 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_summary_by.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_summary_by generates correct expressions", { 2 | result <- template_summary_by( 3 | parentname = "adsl", 4 | dataname = "adlb", 5 | arm_var = "ARM", 6 | id_var = "USUBJID", 7 | sum_vars = c("AVAL"), 8 | add_total = TRUE, 9 | by_vars = c("AVISIT"), 10 | na.rm = FALSE, 11 | denominator = "N", 12 | drop_arm_levels = TRUE, 13 | drop_zero_levels = FALSE 14 | ) 15 | 16 | res <- testthat::expect_silent(result) 17 | testthat::expect_snapshot(res) 18 | }) 19 | 20 | testthat::test_that("template_summary_by generates correct expressions when `parallel_vars` is true", { 21 | result <- template_summary_by( 22 | parentname = "adsl", 23 | dataname = "adlb", 24 | arm_var = "ARM", 25 | id_var = "USUBJID", 26 | sum_vars = c("AVAL", "CHG"), 27 | add_total = TRUE, 28 | parallel_vars = TRUE, 29 | by_vars = c("AVISIT"), 30 | na.rm = FALSE, 31 | denominator = "N", 32 | drop_arm_levels = FALSE, 33 | drop_zero_levels = FALSE 34 | ) 35 | 36 | res <- testthat::expect_silent(result) 37 | testthat::expect_snapshot(res) 38 | }) 39 | 40 | testthat::test_that("template_summary_by generates correct expressions when `row_groups` is true", { 41 | result <- template_summary_by( 42 | parentname = "adsl", 43 | dataname = "adsl", 44 | arm_var = "ARM", 45 | id_var = "USUBJID", 46 | sum_vars = c("AVAL"), 47 | add_total = FALSE, 48 | parallel_vars = FALSE, 49 | row_groups = TRUE, 50 | by_vars = c("SEX", "COUNTRY"), 51 | na.rm = FALSE, 52 | denominator = "N", 53 | drop_arm_levels = TRUE, 54 | drop_zero_levels = FALSE 55 | ) 56 | 57 | res <- testthat::expect_silent(result) 58 | testthat::expect_snapshot(res) 59 | }) 60 | 61 | testthat::test_that("template_summary_by generates correct expressions for customized numeric statistics", { 62 | result <- template_summary_by( 63 | parentname = "adsl", 64 | dataname = "adlb", 65 | arm_var = "ARM", 66 | id_var = "USUBJID", 67 | sum_vars = c("AVAL"), 68 | add_total = TRUE, 69 | by_vars = c("AVISIT"), 70 | na.rm = FALSE, 71 | numeric_stats = c("n"), 72 | denominator = "N", 73 | drop_arm_levels = TRUE, 74 | drop_zero_levels = FALSE 75 | ) 76 | 77 | res <- testthat::expect_silent(result) 78 | testthat::expect_snapshot(res) 79 | }) 80 | 81 | testthat::test_that("template_summary_by generates correct expressions for `drop_zero_levels` is true", { 82 | result <- template_summary_by( 83 | parentname = "adsl", 84 | dataname = "adlb", 85 | arm_var = "ARM", 86 | id_var = "USUBJID", 87 | sum_vars = c("AVAL"), 88 | add_total = TRUE, 89 | by_vars = c("AVISIT"), 90 | na.rm = FALSE, 91 | denominator = "N", 92 | drop_arm_levels = TRUE, 93 | drop_zero_levels = TRUE 94 | ) 95 | 96 | res <- testthat::expect_silent(result) 97 | testthat::expect_snapshot(res) 98 | }) 99 | -------------------------------------------------------------------------------- /tests/testthat/test-tm_t_tte.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("template_tte produces healthy standard output", { 2 | result <- template_tte( 3 | dataname = "ANL", 4 | parentname = "ANL_ADSL", 5 | arm_var = "ARM", 6 | paramcd = "OS", 7 | ref_arm = "B: Placebo", 8 | comp_arm = c("A: Drug X", "C: Combination"), 9 | compare_arm = FALSE, 10 | combine_comp_arms = FALSE, 11 | aval_var = "AVAL", 12 | cnsr_var = "CNSR", 13 | strata_var = NULL, 14 | time_points = c(183, 365, 548), 15 | time_unit_var = "AVALU", 16 | event_desc_var = "EVNTDESC", 17 | control = control_tte( 18 | coxph = control_coxph(), 19 | surv_time = control_surv_time(), 20 | surv_timepoint = control_surv_timepoint() 21 | ) 22 | ) 23 | 24 | res <- testthat::expect_silent(result) 25 | testthat::expect_snapshot(res) 26 | }) 27 | 28 | testthat::test_that("template_tte produces correct data expression when not comparing arms", { 29 | result <- template_tte( 30 | dataname = "ANL", 31 | parentname = "ANL_ADSL", 32 | arm_var = "ARM", 33 | paramcd = "OS", 34 | ref_arm = NULL, 35 | comp_arm = c("A: Drug X", "B: Placebo", "C: Combination"), 36 | compare_arm = FALSE, 37 | combine_comp_arms = TRUE, 38 | aval_var = "AVAL", 39 | cnsr_var = "CNSR", 40 | strata_var = NULL, 41 | time_points = c(183, 365, 548), 42 | time_unit_var = "AVALU", 43 | event_desc_var = "EVNTDESC", 44 | control = control_tte( 45 | coxph = control_coxph(), 46 | surv_time = control_surv_time(), 47 | surv_timepoint = control_surv_timepoint() 48 | ) 49 | ) 50 | 51 | res <- testthat::expect_silent(result) 52 | testthat::expect_snapshot(res) 53 | }) 54 | 55 | testthat::test_that("template_tte produces correct data expression when comparing and combining arms", { 56 | result <- template_tte( 57 | dataname = "ANL", 58 | parentname = "ANL_ADSL", 59 | arm_var = "ARM", 60 | paramcd = "OS", 61 | ref_arm = NULL, 62 | comp_arm = c("A: Drug X", "B: Placebo", "C: Combination"), 63 | compare_arm = TRUE, 64 | combine_comp_arms = TRUE, 65 | aval_var = "AVAL", 66 | cnsr_var = "CNSR", 67 | strata_var = NULL, 68 | time_points = c(183, 365, 548), 69 | time_unit_var = "AVALU", 70 | event_desc_var = "EVNTDESC", 71 | control = control_tte( 72 | coxph = control_coxph(), 73 | surv_time = control_surv_time(), 74 | surv_timepoint = control_surv_timepoint() 75 | ) 76 | ) 77 | 78 | res <- testthat::expect_silent(result) 79 | testthat::expect_snapshot(res) 80 | }) 81 | 82 | testthat::test_that("template_tte produces correct data expression when comparing arms", { 83 | result <- template_tte( 84 | dataname = "ANL", 85 | parentname = "ANL_ADSL", 86 | arm_var = "ARM", 87 | paramcd = "OS", 88 | ref_arm = NULL, 89 | comp_arm = c("A: Drug X", "B: Placebo", "C: Combination"), 90 | compare_arm = TRUE, 91 | combine_comp_arms = FALSE, 92 | aval_var = "AVAL", 93 | cnsr_var = "CNSR", 94 | strata_var = NULL, 95 | time_points = c(183, 365, 548), 96 | time_unit_var = "AVALU", 97 | event_desc_var = "EVNTDESC", 98 | control = control_tte( 99 | coxph = control_coxph(), 100 | surv_time = control_surv_time(), 101 | surv_timepoint = control_surv_timepoint() 102 | ) 103 | ) 104 | 105 | res <- testthat::expect_silent(result) 106 | testthat::expect_snapshot(res) 107 | }) 108 | -------------------------------------------------------------------------------- /tests/testthat/test-validate_standard_inputs.R: -------------------------------------------------------------------------------- 1 | testthat::test_that("validate_arm throws shiny error if arm_vec is not a factor", { 2 | testthat::expect_error( 3 | validate_arm(1:10), 4 | "Treatment variable is not a factor", 5 | class = "shiny.silent.error" 6 | ) 7 | 8 | testthat::expect_error( 9 | validate_arm(c("A", "B", "C")), 10 | "Treatment variable is not a factor", 11 | class = "shiny.silent.error" 12 | ) 13 | }) 14 | 15 | testthat::test_that("validate_arm throws specific shiny error if arm_vec has just whitespace strings", { 16 | testthat::expect_error( 17 | validate_arm(as.factor(c("A", " "))), 18 | "Treatment values cannot contain empty strings", 19 | class = "shiny.silent.error" 20 | ) 21 | 22 | testthat::expect_error( 23 | validate_arm(as.factor(c("A", ""))), 24 | "Treatment values cannot contain empty strings", 25 | class = "shiny.silent.error" 26 | ) 27 | }) 28 | 29 | testthat::test_that("validate_arm throws no error if arm_vec is a factor", { 30 | testthat::expect_no_error( 31 | validate_arm(factor(c("A", "B"), levels = c("A", "B"))) 32 | ) 33 | 34 | testthat::expect_no_error( 35 | validate_arm(factor(c("A", "B"), levels = c("A", "B", "C"))) 36 | ) 37 | }) 38 | --------------------------------------------------------------------------------