├── .Rbuildignore ├── .github ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── cran-release.yml │ └── release.yml └── workflows │ ├── check.yaml │ ├── cla.yaml │ ├── docs.yaml │ ├── post-release.yaml │ ├── release.yaml │ └── scheduled.yaml ├── .gitignore ├── .gitlab-ci.yml ├── .lintr ├── .pre-commit-config.yaml ├── .revdeprefs.yaml ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS.md ├── R ├── 00tabletrees.R ├── Viewer.R ├── argument_conventions.R ├── as_html.R ├── colby_constructors.R ├── compare_rtables.R ├── custom_split_funs.R ├── default_split_funs.R ├── format_rcell.R ├── indent.R ├── index_footnotes.R ├── make_split_fun.R ├── make_subset_expr.R ├── package.R ├── summary.R ├── tree_accessors.R ├── tt_afun_utils.R ├── tt_as_df.R ├── tt_compare_tables.R ├── tt_compatibility.R ├── tt_dotabulation.R ├── tt_export.R ├── tt_from_df.R ├── tt_paginate.R ├── tt_pos_and_access.R ├── tt_showmethods.R ├── tt_sort.R ├── tt_test_afuns.R ├── tt_toString.R ├── utils.R ├── validate_table_struct.R └── zzz_constants.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── inst ├── WORDLIST ├── cheatsheet │ ├── rtables_cheatsheet_01-24.pdf │ ├── rtables_cheatsheet_01-24.pptx │ └── rtables_cheatsheet_01-24_thumbs.png └── extdata │ ├── Advanced_rtables_part1.pdf │ ├── Advances_rtables_part2.pdf │ ├── Clinical_Trial_Reporting_Tables_in_R.pdf │ └── r_adoption_slides.pdf ├── man ├── CellValue.Rd ├── EmptyColInfo.Rd ├── ManualSplit.Rd ├── MultiVarSplit.Rd ├── VarLevelSplit.Rd ├── Viewer.Rd ├── add_colcounts.Rd ├── add_combo_facet.Rd ├── add_existing_table.Rd ├── add_overall_col.Rd ├── add_overall_level.Rd ├── additional_fun_params.Rd ├── analyze.Rd ├── analyze_colvars.Rd ├── append_topleft.Rd ├── as_html.Rd ├── asvec.Rd ├── avarspl.Rd ├── basic_table.Rd ├── brackets.Rd ├── build_table.Rd ├── cbind_rtables.Rd ├── cell_values.Rd ├── cinfo.Rd ├── clear_imods.Rd ├── col_accessors.Rd ├── colcount_visible.Rd ├── collect_leaves.Rd ├── coltree_structure.Rd ├── compare_rtables.Rd ├── compat_args.Rd ├── constr_args.Rd ├── content_table.Rd ├── counts_wpcts.Rd ├── custom_split_funs.Rd ├── cutsplits.Rd ├── data.frame_export.Rd ├── df_to_tt.Rd ├── dimensions.Rd ├── do_base_split.Rd ├── drop_facet_levels.Rd ├── facet_colcount.Rd ├── facet_colcounts_visible-set.Rd ├── figures │ ├── lifecycle-archived.svg │ ├── lifecycle-defunct.svg │ ├── lifecycle-deprecated.svg │ ├── lifecycle-experimental.svg │ ├── lifecycle-maturing.svg │ ├── lifecycle-questioning.svg │ ├── lifecycle-soft-deprecated.svg │ ├── lifecycle-stable.svg │ ├── lifecycle-superseded.svg │ └── logo.svg ├── find_degen_struct.Rd ├── format_rcell.Rd ├── formatters_methods.Rd ├── gen_args.Rd ├── gfc.Rd ├── head_tail.Rd ├── horizontal_sep.Rd ├── in_rows.Rd ├── indent.Rd ├── indent_string.Rd ├── insert_row_at_path.Rd ├── insert_rrow.Rd ├── int_methods.Rd ├── is_rtable.Rd ├── label_at_path.Rd ├── length-CellValue-method.Rd ├── list_wrap.Rd ├── lyt_args.Rd ├── make_afun.Rd ├── make_col_df.Rd ├── make_col_row_df.Rd ├── make_split_fun.Rd ├── make_split_result.Rd ├── manual_cols.Rd ├── matrix_form-VTableTree-method.Rd ├── names.Rd ├── no_info.Rd ├── paginate.Rd ├── prune_table.Rd ├── qtable_layout.Rd ├── rbind.Rd ├── rcell.Rd ├── reexports.Rd ├── ref_fnotes.Rd ├── rheader.Rd ├── rm_all_colcounts.Rd ├── row_accessors.Rd ├── row_paths_summary.Rd ├── rowclasses.Rd ├── rrow.Rd ├── rrowl.Rd ├── rtable.Rd ├── rtables-package.Rd ├── rtinner.Rd ├── sanitize_table_struct.Rd ├── score_funs.Rd ├── section_div.Rd ├── sf_args.Rd ├── sort_at_path.Rd ├── spl_context.Rd ├── spl_context_to_disp_path.Rd ├── spl_variable.Rd ├── split_cols_by.Rd ├── split_cols_by_multivar.Rd ├── split_funcs.Rd ├── split_rows_by.Rd ├── split_rows_by_multivar.Rd ├── subset_cols.Rd ├── summarize_row_groups.Rd ├── tabclasses.Rd ├── table_shell.Rd ├── table_structure.Rd ├── top_left.Rd ├── tostring.Rd ├── tree_children.Rd ├── trim_levels_in_facets.Rd ├── trim_levels_to_map.Rd ├── trim_prune_funs.Rd ├── trim_rows.Rd ├── tsv_io.Rd ├── tt_row_path_exists.Rd ├── ttap.Rd ├── update_ref_indexing.Rd ├── validate_table_struct.Rd ├── value_formats.Rd ├── varcuts.Rd └── vil.Rd ├── pkgdown └── favicon │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico ├── revdep └── .gitignore ├── rtables.Rproj ├── tests ├── testthat.R └── testthat │ ├── setup-fakedata.R │ ├── setup-options.R │ ├── test-accessors.R │ ├── test-as_html.R │ ├── test-binding.R │ ├── test-colby_constructors.R │ ├── test-compare_rtables.R │ ├── test-custom_split_funs.R │ ├── test-default_split_funs.R │ ├── test-deprecated.R │ ├── test-exporters.R │ ├── test-formatting.R │ ├── test-header-footer.R │ ├── test-indent-mod.R │ ├── test-lyt-tabulation.R │ ├── test-make-afun.R │ ├── test-matrix_form.R │ ├── test-pagination.R │ ├── test-printing.R │ ├── test-regressions.R │ ├── test-result_data_frame.R │ ├── test-rtables.R │ ├── test-sanitize-struct.R │ ├── test-sort-prune.R │ ├── test-spanning.R │ ├── test-structure-summary.R │ ├── test-subset-access.R │ ├── test-tab_afun_cfun.R │ └── test_utils.R └── vignettes ├── advanced_usage.Rmd ├── ard_how_to.Rmd ├── baseline.Rmd ├── clinical_trials.Rmd ├── col_counts.Rmd ├── custom_appearance.Rmd ├── dev-guide ├── dg_debug_rtables.Rmd ├── dg_notes.Rmd ├── dg_printing.Rmd ├── dg_split_machinery.Rmd ├── dg_table_hierarchy.Rmd └── dg_tabulation.Rmd ├── example_analysis_coxreg.Rmd ├── exploratory_analysis.Rmd ├── format_precedence.Rmd ├── images └── rtables-basics.png ├── introspecting_tables.Rmd ├── manual_table_construction.Rmd ├── rtables.Rmd ├── sorting_pruning.Rmd ├── split_functions.Rmd ├── subsetting_tables.Rmd ├── tabulation_concepts.Rmd ├── tabulation_dplyr.Rmd └── title_footer.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | (^|/)[#][^/]*#$ 2 | (^|/)\.[#][^/]*$ 3 | .*\.rprof$ 4 | ^.*\.Rproj$ 5 | ^.lintr$ 6 | ^Jenkinsfile$ 7 | ^Meta$ 8 | ^README-.*\.png$ 9 | ^README\.Rmd$ 10 | ^[^/]*.R$ 11 | ^[^/]*html$ 12 | ^[^/]*pdf$ 13 | ^\..*$ 14 | ^\.CI-FORCE-RELEASE-VERSION$ 15 | ^\.Rproj\.user$ 16 | ^\.drone\.yml$ 17 | ^\.github$ 18 | ^\.gitlab-ci\.yml$ 19 | ^\.pre-commit-config\.yaml$ 20 | ^\.travis\.yml$ 21 | ^_pkgdown\.yml$ 22 | ^pkgdown$ 23 | ^doc$ 24 | ^docs$ 25 | ^logs$ 26 | ^man-roxygen$ 27 | ^staged_dependencies\.yaml$ 28 | ^temp$ 29 | ~$ 30 | ^vignettes/dev-guide$ 31 | pkgdown 32 | ^inst/extdata$ 33 | ^inst/cheatsheet$ 34 | ^pkgdown$ 35 | ^.revdeprefs\.yaml$ 36 | ^revdep$ 37 | ^\.covrignore$ 38 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @edelarua @Melkiades @ayogasekaram 2 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [support@github.com](mailto:support@github.com). All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | 77 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Reporting an Issue with rtables 2 | 3 | Do not use this form to ask a question, or ask for assistance. Instead, ask on [Stackoverflow](https://stackoverflow.com/) using the `nest-rtables` tag. Questions about a function's use will be closed without a response. 4 | 5 | Please briefly describe your problem and, when relevant, the output you expect. 6 | Please also provide the output of `utils::sessionInfo()` or 7 | `devtools::session_info()` at the end of your post. 8 | 9 | If at all possible, please include a [minimal, reproducible 10 | example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). 11 | The `rtables` team will be much more likely to resolve your issue if they are 12 | able to reproduce it themselves locally. 13 | 14 | Please delete this preamble after you have read it. 15 | 16 | --- 17 | 18 | your brief description of the problem 19 | 20 | ```r 21 | library(rtables) 22 | 23 | # your reproducible example here 24 | 25 | ``` 26 | -------------------------------------------------------------------------------- /.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 | pull_request: 9 | types: 10 | - opened 11 | - synchronize 12 | - reopened 13 | - ready_for_review 14 | branches: 15 | - main 16 | workflow_dispatch: 17 | 18 | jobs: 19 | docs: 20 | name: Pkgdown Docs 📚 21 | uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main 22 | secrets: 23 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 24 | with: 25 | deps-installation-method: setup-r-dependencies 26 | default-landing-page: latest-tag 27 | additional-unit-test-report-directories: unit-test-report-non-cran 28 | -------------------------------------------------------------------------------- /.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 | build: 12 | name: Build package 🎁 13 | needs: release 14 | uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@main 15 | secrets: 16 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 17 | with: 18 | skip-r-cmd-check: true 19 | skip-r-cmd-install: true 20 | docs: 21 | name: Pkgdown Docs 📚 22 | needs: release 23 | uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main 24 | secrets: 25 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 26 | with: 27 | default-landing-page: latest-release 28 | latest-tag-alt-name: latest-release 29 | branches-or-tags-to-list: ^main$|^latest-release$|^release-candidate$|^v([0-9]+\\.)?([0-9]+\\.)?([0-9]+)|^v([0-9]+\\.)?([0-9]+\\.)?([0-9]+)(-rc[0-9]+)$ 30 | validation: 31 | name: R Package Validation report 📃 32 | needs: release 33 | uses: insightsengineering/r.pkg.template/.github/workflows/validation.yaml@main 34 | secrets: 35 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 36 | release: 37 | name: Create release 🎉 38 | uses: insightsengineering/r.pkg.template/.github/workflows/release.yaml@main 39 | secrets: 40 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 41 | wasm: 42 | name: Build WASM packages 🧑‍🏭 43 | needs: release 44 | uses: insightsengineering/r.pkg.template/.github/workflows/wasm.yaml@main 45 | -------------------------------------------------------------------------------- /.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 | branch-cleanup: 42 | if: > 43 | github.event_name == 'schedule' || ( 44 | github.event_name == 'workflow_dispatch' && 45 | inputs.chosen-workflow == 'branch-cleanup' 46 | ) 47 | name: Branch Cleanup 🧹 48 | uses: insightsengineering/r.pkg.template/.github/workflows/branch-cleanup.yaml@main 49 | secrets: 50 | REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} 51 | cran-status: 52 | name: CRAN Status Monitor 📺 53 | uses: insightsengineering/r.pkg.template/.github/workflows/cran-status.yaml@main 54 | with: 55 | issue-assignees: "shajoezhu,Melkiades,edelarua,ayogasekaram" 56 | revdepcheck: 57 | if: > 58 | github.event_name == 'schedule' || ( 59 | github.event_name == 'workflow_dispatch' && 60 | inputs.chosen-workflow == 'revdepcheck' 61 | ) 62 | name: revdepcheck ↩️ 63 | uses: insightsengineering/r.pkg.template/.github/workflows/revdepcheck.yaml@main 64 | rhub: 65 | if: > 66 | github.event_name == 'schedule' || ( 67 | github.event_name == 'workflow_dispatch' && 68 | inputs.chosen-workflow == 'rhub' 69 | ) 70 | name: R-hub 🌐 71 | uses: insightsengineering/r.pkg.template/.github/workflows/rhub.yaml@main 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | .DS_Store 6 | .httr-oauth 7 | *~ 8 | *.sas.txt 9 | docs/* 10 | temp 11 | 12 | *.rprof 13 | 14 | tmp.R 15 | 16 | tmp.txt 17 | 18 | *.html 19 | 20 | checklog.txt 21 | 22 | currentwork.R 23 | 24 | tablefunexample.R 25 | 26 | broken.R 27 | 28 | complexmodel.R 29 | 30 | *.R# 31 | [^/]*.R 32 | dt_573_MHT01_npaszty.Rmd 33 | 34 | tests/unit_test_results.xml 35 | tests/testthat/Rplots.pdf 36 | 37 | *.prof 38 | /doc/ 39 | /Meta/ 40 | tests/testthat/_snaps/**/*.new.md 41 | tests/testthat/_snaps/**/*.new.svg 42 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | include: 3 | - project: 'nest/automation/gitlab-shared-library' 4 | ref: main 5 | file: R/R_NEST_min.gitlab-ci.yml 6 | -------------------------------------------------------------------------------- /.lintr: -------------------------------------------------------------------------------- 1 | linters: linters_with_defaults( 2 | line_length_linter = line_length_linter(120), 3 | commented_code_linter = NULL, 4 | object_name_linter = NULL, 5 | object_length_linter = NULL, 6 | object_usage_linter = NULL 7 | ) 8 | -------------------------------------------------------------------------------- /.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: roxygenize 12 | additional_dependencies: 13 | - insightsengineering/formatters 14 | - magrittr 15 | - methods 16 | - checkmate 17 | - htmltools 18 | - lifecycle 19 | - stats 20 | - stringi 21 | - id: use-tidy-description 22 | - id: spell-check 23 | exclude: > 24 | (?x)^( 25 | .*\.[rR]| 26 | .*\.feather| 27 | .*\.jpeg| 28 | .*\.pdf| 29 | .*\.png| 30 | .*\.py| 31 | .*\.RData| 32 | .*\.rds| 33 | .*\.Rds| 34 | .*\.Rproj| 35 | .*\.sh| 36 | (.*/|)\.gitignore| 37 | (.*/|)\.covrignore| 38 | (.*/|)\.gitlab-ci\.y[a]?ml| 39 | (.*/|)\.lintr| 40 | (.*/|)\.pre-commit-.*| 41 | (.*/|)\.Rbuildignore| 42 | (.*/|)\.Renviron| 43 | (.*/|)\.Rprofile| 44 | (.*/|)\.travis\.y[a]?ml| 45 | (.*/|)appveyor\.y[a]?ml| 46 | (.*/|)CODEOWNERS| 47 | (.*/|)DESCRIPTION| 48 | (.*/|)LICENSE| 49 | (.*/|)NAMESPACE| 50 | (.*/|)staged_dependencies\.y[a]?ml| 51 | (.*/|)renv/settings\.dcf| 52 | (.*/|)renv\.lock| 53 | (.*/|)WORDLIST| 54 | \.github/workflows/.*| 55 | data/.*| 56 | )$ 57 | - id: readme-rmd-rendered 58 | - id: parsable-R 59 | - id: no-browser-statement 60 | - id: no-debug-statement 61 | - id: deps-in-desc 62 | - repo: https://github.com/pre-commit/pre-commit-hooks 63 | rev: v5.0.0 64 | hooks: 65 | - id: check-added-large-files 66 | args: ['--maxkb=200'] 67 | - id: file-contents-sorter 68 | files: '^\.Rbuildignore$' 69 | - id: end-of-file-fixer 70 | exclude: '\.Rd' 71 | - repo: https://github.com/pre-commit-ci/pre-commit-ci-config 72 | rev: v1.6.1 73 | hooks: 74 | # Only reuiqred when https://pre-commit.ci is used for config validation 75 | - id: check-pre-commit-ci-config 76 | - repo: local 77 | hooks: 78 | - id: forbid-to-commit 79 | name: Don't commit common R artifacts 80 | entry: Cannot commit .Rhistory, .RData, .Rds or .rds. 81 | language: fail 82 | files: '\.(Rhistory|RData|Rds|rds)$' 83 | # `exclude: ` to allow committing specific files 84 | 85 | ci: 86 | autoupdate_schedule: monthly 87 | -------------------------------------------------------------------------------- /.revdeprefs.yaml: -------------------------------------------------------------------------------- 1 | - insightsengineering/tern 2 | - insightsengineering/tern.gee 3 | - insightsengineering/tern.mmrm 4 | - insightsengineering/tern.rbmi 5 | - insightsengineering/scda.test 6 | - insightsengineering/chevron 7 | - insightsengineering/rtables.officer 8 | - insightsengineering/autoslider.core 9 | 10 | -------------------------------------------------------------------------------- /R/Viewer.R: -------------------------------------------------------------------------------- 1 | #' @importFrom utils browseURL 2 | NULL 3 | 4 | #' Display an `rtable` object in the Viewer pane in RStudio or in a browser 5 | #' 6 | #' The table will be displayed using bootstrap styling. 7 | #' 8 | #' @param x (`rtable` or `shiny.tag`)\cr an object of class `rtable` or `shiny.tag` (defined in `htmltools` package). 9 | #' @param y (`rtable` or `shiny.tag`)\cr optional second argument of same type as `x`. 10 | #' @param ... arguments passed to [as_html()]. 11 | #' 12 | #' @return Not meaningful. Called for the side effect of opening a browser or viewer pane. 13 | #' 14 | #' @examples 15 | #' if (interactive()) { 16 | #' sl5 <- factor(iris$Sepal.Length > 5, 17 | #' levels = c(TRUE, FALSE), 18 | #' labels = c("S.L > 5", "S.L <= 5") 19 | #' ) 20 | #' 21 | #' df <- cbind(iris, sl5 = sl5) 22 | #' 23 | #' lyt <- basic_table() %>% 24 | #' split_cols_by("sl5") %>% 25 | #' analyze("Sepal.Length") 26 | #' 27 | #' tbl <- build_table(lyt, df) 28 | #' 29 | #' Viewer(tbl) 30 | #' Viewer(tbl, tbl) 31 | #' 32 | #' 33 | #' tbl2 <- htmltools::tags$div( 34 | #' class = "table-responsive", 35 | #' as_html(tbl, class_table = "table") 36 | #' ) 37 | #' 38 | #' Viewer(tbl, tbl2) 39 | #' } 40 | #' @export 41 | Viewer <- function(x, y = NULL, ...) { 42 | check_convert <- function(x, name, accept_NULL = FALSE) { 43 | if (accept_NULL && is.null(x)) { 44 | NULL 45 | } else if (is(x, "shiny.tag")) { 46 | x 47 | } else if (is(x, "VTableTree")) { 48 | as_html(x, ...) 49 | } else { 50 | stop("object of class rtable or shiny tag excepted for ", name) 51 | } 52 | } 53 | 54 | x_tag <- check_convert(x, "x", FALSE) 55 | y_tag <- check_convert(y, "y", TRUE) 56 | 57 | html_output <- if (is.null(y)) { 58 | x_tag 59 | } else { 60 | tags$div(class = "container-fluid", htmltools::tags$div( 61 | class = "row", 62 | tags$div(class = "col-xs-6", x_tag), 63 | tags$div(class = "col-xs-6", y_tag) 64 | )) 65 | } 66 | 67 | sandbox_folder <- file.path(tempdir(), "rtable") 68 | 69 | if (!dir.exists(sandbox_folder)) { 70 | dir.create(sandbox_folder, recursive = TRUE) 71 | pbs <- file.path(path.package(package = "rtables"), "bootstrap/") 72 | file.copy(list.files(pbs, full.names = TRUE, recursive = FALSE), sandbox_folder, recursive = TRUE) 73 | # list.files(sandbox_folder) 74 | } 75 | 76 | # get html name 77 | n_try <- 10000 78 | for (i in seq_len(n_try)) { 79 | htmlFile <- file.path(sandbox_folder, paste0("table", i, ".html")) 80 | 81 | if (!file.exists(htmlFile)) { 82 | break 83 | } else if (i == n_try) { 84 | stop("too many html rtables created, restart your session") 85 | } 86 | } 87 | 88 | html_bs <- tags$html( 89 | lang = "en", 90 | tags$head( 91 | tags$meta(charset = "utf-8"), 92 | tags$meta("http-equiv" = "X-UA-Compatible", content = "IE=edge"), 93 | tags$meta( 94 | name = "viewport", 95 | content = "width=device-width, initial-scale=1" 96 | ), 97 | tags$title("rtable"), 98 | tags$link( 99 | href = "css/bootstrap.min.css", 100 | rel = "stylesheet" 101 | ) 102 | ), 103 | tags$body( 104 | html_output 105 | ) 106 | ) 107 | 108 | cat( 109 | paste("\n", htmltools::doRenderTags(html_bs)), 110 | file = htmlFile, append = FALSE 111 | ) 112 | 113 | viewer <- getOption("viewer") 114 | 115 | if (!is.null(viewer)) { 116 | viewer(htmlFile) 117 | } else { 118 | browseURL(htmlFile) 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /R/format_rcell.R: -------------------------------------------------------------------------------- 1 | #' Format `rcell` objects 2 | #' 3 | #' This is a wrapper for [formatters::format_value()] for use with `CellValue` objects 4 | #' 5 | #' @inheritParams lyt_args 6 | #' @inheritParams formatters::format_value 7 | #' @param x (`CellValue` or `ANY`)\cr an object of class `CellValue`, or a raw value. 8 | #' @param format (`string` or `function`)\cr the format label or formatter function to 9 | #' apply to `x`. 10 | #' @param output (`string`)\cr output type. 11 | #' @param pr_row_format (`list`)\cr list of default formats coming from the general row. 12 | #' @param pr_row_na_str (`list`)\cr list of default `"NA"` strings coming from the general row. 13 | #' @param shell (`flag`)\cr whether the formats themselves should be returned instead of the 14 | #' values with formats applied. Defaults to `FALSE`. 15 | #' 16 | #' @return Formatted text. 17 | #' 18 | #' @examples 19 | #' cll <- CellValue(pi, format = "xx.xxx") 20 | #' format_rcell(cll) 21 | #' 22 | #' # Cell values precedes the row values 23 | #' cll <- CellValue(pi, format = "xx.xxx") 24 | #' format_rcell(cll, pr_row_format = "xx.x") 25 | #' 26 | #' # Similarly for NA values 27 | #' cll <- CellValue(NA, format = "xx.xxx", format_na_str = "This is THE NA") 28 | #' format_rcell(cll, pr_row_na_str = "This is NA") 29 | #' 30 | #' @export 31 | format_rcell <- function(x, format, 32 | output = c("ascii", "html"), 33 | na_str = obj_na_str(x) %||% "NA", 34 | pr_row_format = NULL, 35 | pr_row_na_str = NULL, 36 | round_type = c("iec", "sas"), 37 | shell = FALSE) { 38 | # Check for format and parent row format 39 | format <- if (missing(format)) obj_format(x) else format 40 | if (is.null(format) && !is.null(pr_row_format)) { 41 | format <- pr_row_format 42 | } 43 | # Check for na_str from parent 44 | if (is.null(obj_na_str(x)) && !is.null(pr_row_na_str)) { 45 | na_str <- pr_row_na_str 46 | } 47 | 48 | # Main call to external function or shell 49 | if (shell) { 50 | return(format) 51 | } 52 | format_value(rawvalues(x), 53 | format = format, 54 | output = output, 55 | na_str = na_str, 56 | round_type = round_type 57 | ) 58 | } 59 | -------------------------------------------------------------------------------- /R/indent.R: -------------------------------------------------------------------------------- 1 | #' Change indentation of all `rrows` in an `rtable` 2 | #' 3 | #' Change indentation of all `rrows` in an `rtable` 4 | #' 5 | #' @param x (`VTableTree`)\cr an `rtable` object. 6 | #' @param by (`integer`)\cr number to increase indentation of rows by. Can be negative. If final indentation is 7 | #' less than 0, the indentation is set to 0. 8 | #' 9 | #' @return `x` with its indent modifier incremented by `by`. 10 | #' 11 | #' @examples 12 | #' is_setosa <- iris$Species == "setosa" 13 | #' m_tbl <- rtable( 14 | #' header = rheader( 15 | #' rrow(row.name = NULL, rcell("Sepal.Length", colspan = 2), rcell("Petal.Length", colspan = 2)), 16 | #' rrow(NULL, "mean", "median", "mean", "median") 17 | #' ), 18 | #' rrow( 19 | #' row.name = "All Species", 20 | #' mean(iris$Sepal.Length), median(iris$Sepal.Length), 21 | #' mean(iris$Petal.Length), median(iris$Petal.Length), 22 | #' format = "xx.xx" 23 | #' ), 24 | #' rrow( 25 | #' row.name = "Setosa", 26 | #' mean(iris$Sepal.Length[is_setosa]), median(iris$Sepal.Length[is_setosa]), 27 | #' mean(iris$Petal.Length[is_setosa]), median(iris$Petal.Length[is_setosa]), 28 | #' format = "xx.xx" 29 | #' ) 30 | #' ) 31 | #' indent(m_tbl) 32 | #' indent(m_tbl, 2) 33 | #' 34 | #' @export 35 | indent <- function(x, by = 1) { 36 | if (nrow(x) == 0 || by == 0) { 37 | return(x) 38 | } 39 | 40 | indent_mod(x) <- indent_mod(x) + by 41 | x 42 | } 43 | 44 | #' Clear all indent modifiers from a table 45 | #' 46 | #' @inheritParams gen_args 47 | #' 48 | #' @return The same class as `tt`, with all indent modifiers set to zero. 49 | #' 50 | #' @examples 51 | #' lyt1 <- basic_table() %>% 52 | #' summarize_row_groups("STUDYID", label_fstr = "overall summary") %>% 53 | #' split_rows_by("AEBODSYS", child_labels = "visible") %>% 54 | #' summarize_row_groups("STUDYID", label_fstr = "subgroup summary") %>% 55 | #' analyze("AGE", indent_mod = -1L) 56 | #' 57 | #' tbl1 <- build_table(lyt1, ex_adae) 58 | #' tbl1 59 | #' clear_indent_mods(tbl1) 60 | #' 61 | #' @export 62 | #' @rdname clear_imods 63 | setGeneric("clear_indent_mods", function(tt) standardGeneric("clear_indent_mods")) 64 | 65 | #' @export 66 | #' @rdname clear_imods 67 | setMethod( 68 | "clear_indent_mods", "VTableTree", 69 | function(tt) { 70 | ct <- content_table(tt) 71 | if (!is.null(ct)) { 72 | content_table(tt) <- clear_indent_mods(ct) 73 | } 74 | tree_children(tt) <- lapply(tree_children(tt), clear_indent_mods) 75 | indent_mod(tt) <- 0L 76 | tt 77 | } 78 | ) 79 | 80 | #' @export 81 | #' @rdname clear_imods 82 | setMethod( 83 | "clear_indent_mods", "TableRow", 84 | function(tt) { 85 | indent_mod(tt) <- 0L 86 | tt 87 | } 88 | ) 89 | -------------------------------------------------------------------------------- /R/package.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | "_PACKAGE" 3 | 4 | #' @importFrom utils head head.matrix tail tail.matrix 5 | #' @importFrom stats setNames na.omit prop.test binom.test relevel quantile 6 | #' @importFrom htmltools tags tagList 7 | #' @importFrom lifecycle deprecated 8 | #' @importFrom magrittr %>% 9 | #' @import methods 10 | NULL 11 | -------------------------------------------------------------------------------- /R/tt_export.R: -------------------------------------------------------------------------------- 1 | #' @importFrom tools file_ext 2 | NULL 3 | 4 | #' Create enriched flat value table with paths 5 | #' 6 | #' This function creates a flat tabular file of cell values and corresponding paths via [path_enriched_df()]. It then 7 | #' writes that data frame out as a `tsv` file. 8 | #' 9 | #' By default (i.e. when `value_func` is not specified, list columns where at least one value has length > 1 are 10 | #' collapsed to character vectors by collapsing the list element with `"|"`. 11 | #' 12 | #' @note 13 | #' There is currently no round-trip capability for this type of export. You can read values exported this way back in 14 | #' via `import_from_tsv` but you will receive only the `data.frame` version back, NOT a `TableTree`. 15 | #' 16 | #' @inheritParams gen_args 17 | #' @inheritParams data.frame_export 18 | #' @param file (`string`)\cr the path of the file to written to or read from. 19 | #' @param sep (`string`)\cr defaults to `\t`. See [utils::write.table()] for more details. 20 | #' @param ... (`any`)\cr additional arguments to be passed to [utils::write.table()]. 21 | #' 22 | #' @return 23 | #' * `export_as_tsv` returns `NULL` silently. 24 | #' * `import_from_tsv` returns a `data.frame` with re-constituted list values. 25 | #' 26 | #' @seealso [path_enriched_df()] for the underlying function that does the work. 27 | #' 28 | #' @importFrom utils write.table read.table 29 | #' @rdname tsv_io 30 | #' @export 31 | export_as_tsv <- function(tt, file = NULL, path_fun = collapse_path, 32 | value_fun = collapse_values, sep = "\t", ...) { 33 | df <- path_enriched_df(tt, path_fun = path_fun, value_fun = value_fun) 34 | write.table(df, file, sep = sep, ...) 35 | } 36 | 37 | #' @rdname tsv_io 38 | #' @export 39 | import_from_tsv <- function(file) { 40 | rawdf <- read.table(file, header = TRUE, sep = "\t") 41 | as.data.frame(lapply( 42 | rawdf, 43 | function(col) { 44 | if (!any(grepl(.collapse_char, col, fixed = TRUE))) { 45 | col 46 | } else { 47 | I(strsplit(col, split = .collapse_char_esc)) 48 | } 49 | } 50 | )) 51 | } 52 | # txt (formatters) -------------------------------------------------------------------- 53 | #' @importFrom formatters export_as_txt 54 | #' 55 | #' @examples 56 | #' lyt <- basic_table() %>% 57 | #' split_cols_by("ARM") %>% 58 | #' analyze(c("AGE", "BMRKR2", "COUNTRY")) 59 | #' 60 | #' tbl <- build_table(lyt, ex_adsl) 61 | #' 62 | #' cat(export_as_txt(tbl, file = NULL, paginate = TRUE, lpp = 8)) 63 | #' 64 | #' \dontrun{ 65 | #' tf <- tempfile(fileext = ".txt") 66 | #' export_as_txt(tbl, file = tf) 67 | #' system2("cat", tf) 68 | #' } 69 | #' 70 | #' @export 71 | formatters::export_as_txt 72 | 73 | # pdf (formatters) ---------------------------------------------------------- 74 | #' @importFrom formatters export_as_pdf 75 | #' 76 | #' @examples 77 | #' lyt <- basic_table() %>% 78 | #' split_cols_by("ARM") %>% 79 | #' analyze(c("AGE", "BMRKR2", "COUNTRY")) 80 | #' 81 | #' tbl <- build_table(lyt, ex_adsl) 82 | #' 83 | #' \dontrun{ 84 | #' tf <- tempfile(fileext = ".pdf") 85 | #' export_as_pdf(tbl, file = tf, pg_height = 4) 86 | #' tf <- tempfile(fileext = ".pdf") 87 | #' export_as_pdf(tbl, file = tf, lpp = 8) 88 | #' } 89 | #' 90 | #' @export 91 | formatters::export_as_pdf 92 | -------------------------------------------------------------------------------- /R/tt_from_df.R: -------------------------------------------------------------------------------- 1 | #' Create an `ElementaryTable` from a `data.frame` 2 | #' 3 | #' @param df (`data.frame`)\cr a data frame. 4 | #' 5 | #' @details 6 | #' If row names are not defined in `df` (or they are simple numbers), then the row names are taken from the column 7 | #' `label_name`, if it exists. If `label_name` exists, then it is also removed from the original data. This behavior 8 | #' is compatible with [as_result_df()], when `as_is = TRUE` and the row names are not unique. 9 | #' 10 | #' @seealso [as_result_df()] for the inverse operation. 11 | #' 12 | #' @examples 13 | #' df_to_tt(mtcars) 14 | #' 15 | #' @export 16 | df_to_tt <- function(df) { 17 | colnms <- colnames(df) 18 | cinfo <- manual_cols(colnms) 19 | rnames <- rownames(df) 20 | havern <- !is.null(rnames) 21 | 22 | if ((!havern || all(grepl("[0-9]+", rnames))) && "label_name" %in% colnms) { 23 | rnames <- df$label_name 24 | df <- df[, -match("label_name", colnms)] 25 | colnms <- colnames(df) 26 | cinfo <- manual_cols(colnms) 27 | havern <- TRUE 28 | } 29 | 30 | kids <- lapply(seq_len(nrow(df)), function(i) { 31 | rni <- if (havern) rnames[i] else "" 32 | do.call(rrow, c(list(row.name = rni), unclass(df[i, ]))) 33 | }) 34 | 35 | ElementaryTable(kids = kids, cinfo = cinfo) 36 | } 37 | -------------------------------------------------------------------------------- /R/tt_test_afuns.R: -------------------------------------------------------------------------------- 1 | ## We actually make one so we can ensure the generated code itself has coverage... 2 | 3 | test_sfunx <- function(x, .N_total) { # nocov start 4 | c(as.list(summary(x)), list(grp = list( 5 | range = range(x), n_unique = c(.N_total, length(unique(x))) 6 | ))) 7 | } # nocov end 8 | 9 | test_afun <- make_afun(test_sfunx, 10 | .labels = c( 11 | "Min." = "Minimum", 12 | "1st Qu." = "1st Quartile", 13 | "3rd Qu." = "Third Quartile", 14 | "Max." = "Maximum" 15 | ), 16 | .formats = c( 17 | "Min." = "xx.x", 18 | "1st Qu." = "xx.xx", 19 | "3rd Qu." = "xx.xx", 20 | "Max." = "xx.x" 21 | ) 22 | ) 23 | 24 | test_afun_grp <- make_afun(test_afun, 25 | .formats = c(grp = "xx - xx"), 26 | .ungroup_stats = "grp" 27 | ) 28 | 29 | test_sfundf <- function(df, .N_total) { # nocov start 30 | x <- df[[1]] 31 | c( 32 | as.list(summary(x)), 33 | list(grp = list( 34 | range = range(x), 35 | n_unique = c(.N_total, length(unique(x))) 36 | )) 37 | ) 38 | } # nocov end 39 | 40 | test_afundf <- make_afun(test_sfundf, 41 | .labels = c( 42 | "Min." = "Minimum", 43 | "1st Qu." = "1st Quartile", 44 | "3rd Qu." = "Third Quartile", 45 | "Max." = "Maximum" 46 | ), 47 | .formats = c( 48 | "Min." = "xx.x", 49 | "1st Qu." = "xx.xx", 50 | "3rd Qu." = "xx.xx", 51 | "Max." = "xx.x" 52 | ) 53 | ) 54 | -------------------------------------------------------------------------------- /R/zzz_constants.R: -------------------------------------------------------------------------------- 1 | # nocov start 2 | 3 | ## Empty default objects to avoid repeated calls 4 | .onLoad <- function(libname, pkgname) { 5 | ns <- asNamespace(pkgname) 6 | delayedAssign("EmptyColInfo", InstantiatedColumnInfo(), 7 | assign.env = ns 8 | ) 9 | delayedAssign("EmptyElTable", ElementaryTable(), 10 | assign.env = ns 11 | ) 12 | delayedAssign("empty_table", rtable(" "), 13 | assign.env = ns 14 | ) 15 | delayedAssign("EmptyRootSplit", RootSplit(), 16 | assign.env = ns 17 | ) ## is this used? 18 | delayedAssign("EmptyAllSplit", AllSplit(), 19 | assign.env = ns 20 | ) ## is this used? 21 | namespaceExport(ns, c("EmptyColInfo", "EmptyElTable")) 22 | } 23 | 24 | #' Empty table, column, split objects 25 | #' @name EmptyColInfo 26 | #' @aliases EmptyElTable EmptyRootSplit EmptyAllSplit 27 | #' @description Empty objects of various types to compare against efficiently. 28 | NULL 29 | 30 | # nocov end 31 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | ARD 2 | ARDs 3 | Bové 4 | CRAN's 5 | Carreras 6 | Cheatsheet 7 | Chohan 8 | FFFL 9 | Godwin 10 | Heng 11 | Hoffmann 12 | IEC 13 | Kelkhoff 14 | Layouting 15 | Lewandowski 16 | Maximo 17 | Modelling 18 | NSE 19 | ORCID 20 | Paszty 21 | Pathing 22 | Pharma 23 | Phuse 24 | Pre 25 | Qi 26 | RStudio 27 | Resync 28 | Rua 29 | STUDYID 30 | Sabanés 31 | Saibah 32 | Stoilova 33 | Subtable 34 | Subtables 35 | Tadeusz 36 | Unstratified 37 | ValueWrapper 38 | Yung 39 | afun 40 | amongst 41 | ard 42 | charset 43 | combinatorial 44 | customizations 45 | de 46 | decrementing 47 | df 48 | dimensioned 49 | divs 50 | dplyr 51 | elemtable 52 | emph 53 | facetted 54 | facetting 55 | formatter 56 | forseeable 57 | funder 58 | getter 59 | getters 60 | ie 61 | iec 62 | ing 63 | initializer 64 | labelled 65 | layouting 66 | mandatorily 67 | monospace 68 | multivariable 69 | orderable 70 | pathability 71 | pathable 72 | pathed 73 | pathing 74 | peforms 75 | postfix 76 | postprocessing 77 | pre 78 | reindexed 79 | repped 80 | responder 81 | reusability 82 | roadmap 83 | sas 84 | sortable 85 | spl 86 | subsplits 87 | subtable 88 | subtable's 89 | subtables 90 | summarization 91 | tableone 92 | todo 93 | traversable 94 | truetype 95 | unaggregated 96 | unicode 97 | uniqify 98 | univariable 99 | unnested 100 | unpruned 101 | unstratified 102 | useR 103 | visibilty 104 | visiblities 105 | xtable 106 | -------------------------------------------------------------------------------- /inst/cheatsheet/rtables_cheatsheet_01-24.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/inst/cheatsheet/rtables_cheatsheet_01-24.pdf -------------------------------------------------------------------------------- /inst/cheatsheet/rtables_cheatsheet_01-24.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/inst/cheatsheet/rtables_cheatsheet_01-24.pptx -------------------------------------------------------------------------------- /inst/cheatsheet/rtables_cheatsheet_01-24_thumbs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/inst/cheatsheet/rtables_cheatsheet_01-24_thumbs.png -------------------------------------------------------------------------------- /inst/extdata/Advanced_rtables_part1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/inst/extdata/Advanced_rtables_part1.pdf -------------------------------------------------------------------------------- /inst/extdata/Advances_rtables_part2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/inst/extdata/Advances_rtables_part2.pdf -------------------------------------------------------------------------------- /inst/extdata/Clinical_Trial_Reporting_Tables_in_R.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/inst/extdata/Clinical_Trial_Reporting_Tables_in_R.pdf -------------------------------------------------------------------------------- /inst/extdata/r_adoption_slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/inst/extdata/r_adoption_slides.pdf -------------------------------------------------------------------------------- /man/CellValue.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00tabletrees.R 3 | \name{CellValue} 4 | \alias{CellValue} 5 | \title{Constructor for Cell Value} 6 | \usage{ 7 | CellValue( 8 | val, 9 | format = NULL, 10 | colspan = 1L, 11 | label = NULL, 12 | indent_mod = NULL, 13 | footnotes = NULL, 14 | align = NULL, 15 | format_na_str = NULL, 16 | stat_names = NA_character_ 17 | ) 18 | } 19 | \arguments{ 20 | \item{val}{(\code{ANY})\cr value in the cell exactly as it should be passed to a formatter or returned when extracted.} 21 | 22 | \item{format}{(\code{string}, \code{function}, or \code{list})\cr format associated with this split. Formats can be declared via 23 | strings (\code{"xx.x"}) or function. In cases such as \code{analyze} calls, they can be character vectors or lists of 24 | functions. See \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for a list of all available format strings.} 25 | 26 | \item{colspan}{(\code{integer(1)})\cr column span value.} 27 | 28 | \item{label}{(\code{string})\cr a label (not to be confused with the name) for the object/structure.} 29 | 30 | \item{indent_mod}{(\code{numeric})\cr modifier for the default indent position for the structure created by this 31 | function (subtable, content table, or row) \emph{and all of that structure's children}. Defaults to 0, which 32 | corresponds to the unmodified default behavior.} 33 | 34 | \item{footnotes}{(\code{list} or \code{NULL})\cr referential footnote messages for the cell.} 35 | 36 | \item{align}{(\code{string} or \code{NULL})\cr alignment the value should be rendered with. Defaults to \code{"center"} if 37 | \code{NULL} is used. See \code{\link[formatters:list_formats]{formatters::list_valid_aligns()}} for all currently supported alignments.} 38 | 39 | \item{format_na_str}{(\code{string})\cr string which should be displayed when formatted if this cell's value(s) 40 | are all \code{NA}.} 41 | 42 | \item{stat_names}{(\code{character} or \code{NA})\cr names for the statistics in the cell. It can be a vector of strings. 43 | If \code{NA}, statistic names are not specified.} 44 | } 45 | \value{ 46 | An object representing the value within a single cell within a populated table. The underlying structure 47 | of this object is an implementation detail and should not be relied upon beyond calling accessors for the class. 48 | } 49 | \description{ 50 | Constructor for Cell Value 51 | } 52 | -------------------------------------------------------------------------------- /man/EmptyColInfo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz_constants.R 3 | \name{EmptyColInfo} 4 | \alias{EmptyColInfo} 5 | \alias{EmptyElTable} 6 | \alias{EmptyRootSplit} 7 | \alias{EmptyAllSplit} 8 | \title{Empty table, column, split objects} 9 | \description{ 10 | Empty objects of various types to compare against efficiently. 11 | } 12 | -------------------------------------------------------------------------------- /man/ManualSplit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00tabletrees.R 3 | \name{ManualSplit} 4 | \alias{ManualSplit} 5 | \title{Manually defined split} 6 | \usage{ 7 | ManualSplit( 8 | levels, 9 | label, 10 | name = "manual", 11 | extra_args = list(), 12 | indent_mod = 0L, 13 | cindent_mod = 0L, 14 | cvar = "", 15 | cextra_args = list(), 16 | label_pos = "visible", 17 | page_prefix = NA_character_, 18 | section_div = NA_character_ 19 | ) 20 | } 21 | \arguments{ 22 | \item{levels}{(\code{character})\cr levels of the split (i.e. the children of the manual split).} 23 | 24 | \item{label}{(\code{string})\cr a label (not to be confused with the name) for the object/structure.} 25 | 26 | \item{name}{(\code{string})\cr name of the split/table/row being created. Defaults to the value of the 27 | corresponding label, but is not required to be.} 28 | 29 | \item{extra_args}{(\code{list})\cr extra arguments to be passed to the tabulation function. Element position in the list 30 | corresponds to the children of this split. Named elements in the child-specific lists are ignored if they do 31 | not match a formal argument of the tabulation function.} 32 | 33 | \item{indent_mod}{(\code{numeric})\cr modifier for the default indent position for the structure created by this 34 | function (subtable, content table, or row) \emph{and all of that structure's children}. Defaults to 0, which 35 | corresponds to the unmodified default behavior.} 36 | 37 | \item{cindent_mod}{(\code{numeric(1)})\cr the indent modifier for the content tables generated by this split.} 38 | 39 | \item{cvar}{(\code{string})\cr the variable, if any, that the content function should accept. Defaults to \code{NA}.} 40 | 41 | \item{cextra_args}{(\code{list})\cr extra arguments to be passed to the content function when tabulating row group 42 | summaries.} 43 | 44 | \item{label_pos}{(\code{string})\cr location where the variable label should be displayed. Accepts \code{"hidden"} 45 | (default for non-analyze row splits), \code{"visible"}, \code{"topleft"}, and \code{"default"} (for analyze splits only). For 46 | \code{analyze} calls, \code{"default"} indicates that the variable should be visible if and only if multiple variables are 47 | analyzed at the same level of nesting.} 48 | 49 | \item{page_prefix}{(\code{string})\cr prefix to be appended with the split value when forcing pagination between 50 | the children of a split/table.} 51 | 52 | \item{section_div}{(\code{string})\cr string which should be repeated as a section divider after each group defined 53 | by this split instruction, or \code{NA_character_} (the default) for no section divider.} 54 | } 55 | \value{ 56 | A \code{ManualSplit} object. 57 | } 58 | \description{ 59 | Manually defined split 60 | } 61 | \author{ 62 | Gabriel Becker 63 | } 64 | -------------------------------------------------------------------------------- /man/Viewer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Viewer.R 3 | \name{Viewer} 4 | \alias{Viewer} 5 | \title{Display an \code{rtable} object in the Viewer pane in RStudio or in a browser} 6 | \usage{ 7 | Viewer(x, y = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{rtable} or \code{shiny.tag})\cr an object of class \code{rtable} or \code{shiny.tag} (defined in \code{htmltools} package).} 11 | 12 | \item{y}{(\code{rtable} or \code{shiny.tag})\cr optional second argument of same type as \code{x}.} 13 | 14 | \item{...}{arguments passed to \code{\link[=as_html]{as_html()}}.} 15 | } 16 | \value{ 17 | Not meaningful. Called for the side effect of opening a browser or viewer pane. 18 | } 19 | \description{ 20 | The table will be displayed using bootstrap styling. 21 | } 22 | \examples{ 23 | if (interactive()) { 24 | sl5 <- factor(iris$Sepal.Length > 5, 25 | levels = c(TRUE, FALSE), 26 | labels = c("S.L > 5", "S.L <= 5") 27 | ) 28 | 29 | df <- cbind(iris, sl5 = sl5) 30 | 31 | lyt <- basic_table() \%>\% 32 | split_cols_by("sl5") \%>\% 33 | analyze("Sepal.Length") 34 | 35 | tbl <- build_table(lyt, df) 36 | 37 | Viewer(tbl) 38 | Viewer(tbl, tbl) 39 | 40 | 41 | tbl2 <- htmltools::tags$div( 42 | class = "table-responsive", 43 | as_html(tbl, class_table = "table") 44 | ) 45 | 46 | Viewer(tbl, tbl2) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /man/add_colcounts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{add_colcounts} 4 | \alias{add_colcounts} 5 | \title{Add the column population counts to the header} 6 | \usage{ 7 | add_colcounts(lyt, format = "(N=xx)") 8 | } 9 | \arguments{ 10 | \item{lyt}{(\code{PreDataTableLayouts})\cr layout object pre-data used for tabulation.} 11 | 12 | \item{format}{(\code{string}, \code{function}, or \code{list})\cr format associated with this split. Formats can be declared via 13 | strings (\code{"xx.x"}) or function. In cases such as \code{analyze} calls, they can be character vectors or lists of 14 | functions. See \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for a list of all available format strings.} 15 | } 16 | \value{ 17 | A \code{PreDataTableLayouts} object suitable for passing to further layouting functions, and to \code{\link[=build_table]{build_table()}}. 18 | } 19 | \description{ 20 | Add the data derived column counts. 21 | } 22 | \details{ 23 | It is often the case that the the column counts derived from the 24 | input data to \code{\link[=build_table]{build_table()}} is not representative of the population counts. 25 | For example, if events are counted in the table and the header should 26 | display the number of subjects and not the total number of events. 27 | } 28 | \examples{ 29 | lyt <- basic_table() \%>\% 30 | split_cols_by("ARM") \%>\% 31 | add_colcounts() \%>\% 32 | split_rows_by("RACE", split_fun = drop_split_levels) \%>\% 33 | analyze("AGE", afun = function(x) list(min = min(x), max = max(x))) 34 | lyt 35 | 36 | tbl <- build_table(lyt, DM) 37 | tbl 38 | 39 | } 40 | \author{ 41 | Gabriel Becker 42 | } 43 | -------------------------------------------------------------------------------- /man/add_combo_facet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/make_split_fun.R 3 | \name{add_combo_facet} 4 | \alias{add_combo_facet} 5 | \alias{add_overall_facet} 6 | \title{Add a combination facet in post-processing} 7 | \usage{ 8 | add_combo_facet(name, label = name, levels, extra = list()) 9 | 10 | add_overall_facet(name, label, extra = list()) 11 | } 12 | \arguments{ 13 | \item{name}{(\code{string})\cr name for the resulting facet (for use in pathing, etc.).} 14 | 15 | \item{label}{(\code{string})\cr label for the resulting facet.} 16 | 17 | \item{levels}{(\code{character})\cr vector of levels to combine within the resulting facet.} 18 | 19 | \item{extra}{(\code{list})\cr extra arguments to be passed to analysis functions applied within the resulting facet.} 20 | } 21 | \value{ 22 | A function which can be used within the \code{post} argument in \code{\link[=make_split_fun]{make_split_fun()}}. 23 | } 24 | \description{ 25 | Add a combination facet during the post-processing stage in a custom split fun. 26 | } 27 | \details{ 28 | For \code{add_combo_facet}, the data associated with the resulting facet will be the data associated with the facets for 29 | each level in \code{levels}, row-bound together. In particular, this means that if those levels are overlapping, data 30 | that appears in both will be duplicated. 31 | } 32 | \examples{ 33 | mysplfun <- make_split_fun(post = list( 34 | add_combo_facet("A_B", 35 | label = "Arms A+B", 36 | levels = c("A: Drug X", "B: Placebo") 37 | ), 38 | add_overall_facet("ALL", label = "All Arms") 39 | )) 40 | 41 | lyt <- basic_table(show_colcounts = TRUE) \%>\% 42 | split_cols_by("ARM", split_fun = mysplfun) \%>\% 43 | analyze("AGE") 44 | 45 | tbl <- build_table(lyt, DM) 46 | 47 | } 48 | \seealso{ 49 | \code{\link[=make_split_fun]{make_split_fun()}} 50 | 51 | Other make_custom_split: 52 | \code{\link{drop_facet_levels}()}, 53 | \code{\link{make_split_fun}()}, 54 | \code{\link{make_split_result}()}, 55 | \code{\link{trim_levels_in_facets}()} 56 | } 57 | \concept{make_custom_split} 58 | -------------------------------------------------------------------------------- /man/add_existing_table.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{add_existing_table} 4 | \alias{add_existing_table} 5 | \title{Add an already calculated table to the layout} 6 | \usage{ 7 | add_existing_table(lyt, tt, indent_mod = 0) 8 | } 9 | \arguments{ 10 | \item{lyt}{(\code{PreDataTableLayouts})\cr layout object pre-data used for tabulation.} 11 | 12 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 13 | 14 | \item{indent_mod}{(\code{numeric})\cr modifier for the default indent position for the structure created by this 15 | function (subtable, content table, or row) \emph{and all of that structure's children}. Defaults to 0, which 16 | corresponds to the unmodified default behavior.} 17 | } 18 | \value{ 19 | A \code{PreDataTableLayouts} object suitable for passing to further layouting functions, and to \code{\link[=build_table]{build_table()}}. 20 | } 21 | \description{ 22 | Add an already calculated table to the layout 23 | } 24 | \examples{ 25 | lyt1 <- basic_table() \%>\% 26 | split_cols_by("ARM") \%>\% 27 | analyze("AGE", afun = mean, format = "xx.xx") 28 | 29 | tbl1 <- build_table(lyt1, DM) 30 | tbl1 31 | 32 | lyt2 <- basic_table() \%>\% 33 | split_cols_by("ARM") \%>\% 34 | analyze("AGE", afun = sd, format = "xx.xx") \%>\% 35 | add_existing_table(tbl1) 36 | 37 | tbl2 <- build_table(lyt2, DM) 38 | tbl2 39 | 40 | table_structure(tbl2) 41 | row_paths_summary(tbl2) 42 | 43 | } 44 | \author{ 45 | Gabriel Becker 46 | } 47 | -------------------------------------------------------------------------------- /man/add_overall_col.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{add_overall_col} 4 | \alias{add_overall_col} 5 | \title{Add overall column} 6 | \usage{ 7 | add_overall_col(lyt, label) 8 | } 9 | \arguments{ 10 | \item{lyt}{(\code{PreDataTableLayouts})\cr layout object pre-data used for tabulation.} 11 | 12 | \item{label}{(\code{string})\cr a label (not to be confused with the name) for the object/structure.} 13 | } 14 | \value{ 15 | A \code{PreDataTableLayouts} object suitable for passing to further layouting functions, and to \code{\link[=build_table]{build_table()}}. 16 | } 17 | \description{ 18 | This function will \emph{only} add an overall column at the \emph{top} level of splitting, NOT within existing column splits. 19 | See \code{\link[=add_overall_level]{add_overall_level()}} for the recommended way to add overall columns more generally within existing splits. 20 | } 21 | \examples{ 22 | lyt <- basic_table() \%>\% 23 | split_cols_by("ARM") \%>\% 24 | add_overall_col("All Patients") \%>\% 25 | analyze("AGE") 26 | lyt 27 | 28 | tbl <- build_table(lyt, DM) 29 | tbl 30 | 31 | } 32 | \seealso{ 33 | \code{\link[=add_overall_level]{add_overall_level()}} 34 | } 35 | -------------------------------------------------------------------------------- /man/additional_fun_params.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{additional_fun_params} 4 | \alias{additional_fun_params} 5 | \title{Additional parameters within analysis and content functions (\code{afun}/\code{cfun})} 6 | \description{ 7 | It is possible to add specific parameters to \code{afun} and \code{cfun}, in \code{\link[=analyze]{analyze()}} and \code{\link[=summarize_row_groups]{summarize_row_groups()}}, 8 | respectively. These parameters grant access to relevant information like the row split structure (see 9 | \link{spl_context}) and the predefined baseline (\code{.ref_group}). 10 | } 11 | \details{ 12 | We list and describe all the parameters that can be added to a custom analysis function below: 13 | 14 | \describe{ 15 | \item{.N_col}{Column-wise N (column count) for the full column being tabulated within.} 16 | \item{.N_total}{Overall N (all observation count, defined as sum of column counts) for the tabulation.} 17 | \item{.N_row}{Row-wise N (row group count) for the group of observations being analyzed (i.e. with no 18 | column-based subsetting).} 19 | \item{.df_row}{\code{data.frame} for observations in the row group being analyzed (i.e. with no column-based 20 | subsetting).} 21 | \item{.var}{Variable being analyzed.} 22 | \item{.ref_group}{\code{data.frame} or vector of subset corresponding to the \code{ref_group} column including subsetting 23 | defined by row-splitting. Only required/meaningful if a \code{ref_group} column has been defined.} 24 | \item{.ref_full}{\code{data.frame} or vector of subset corresponding to the \code{ref_group} column without subsetting 25 | defined by row-splitting. Only required/meaningful if a \code{ref_group} column has been defined.} 26 | \item{.in_ref_col}{Boolean indicating if calculation is done for cells within the reference column.} 27 | \item{.spl_context}{\code{data.frame} where each row gives information about a previous 'ancestor' split state. 28 | See \link{spl_context}.} 29 | \item{.alt_df_row}{\code{data.frame}, i.e. the \code{alt_counts_df} after row splitting. It can be used with 30 | \code{.all_col_exprs} and \code{.spl_context} information to retrieve current faceting, but for \code{alt_count_df}. 31 | It can be an empty table if all the entries are filtered out.} 32 | \item{.alt_df}{\code{data.frame}, \code{.alt_df_row} but filtered by columns expression. This data present the same 33 | faceting of main data \code{df}. This also filters \code{NA}s out if related parameters are set to do so (e.g. \code{inclNAs} 34 | in \code{\link[=analyze]{analyze()}}). Similarly to \code{.alt_df_row}, it can be an empty data.frame if all the entries are filtered out.} 35 | \item{.alt_df_full}{\code{data.frame}, the full \code{alt_counts_df} as passed into \code{build_table}. 36 | Unlike \code{.alt_df} and \code{.alt_df_row}, this parameter can be used in cases 37 | where the variables required for row splitting are not present in \code{alt_counts_df}.} 38 | \item{.all_col_exprs}{List of expressions. Each of them represents a different column splitting.} 39 | \item{.all_col_counts}{Vector of integers. Each of them represents the global count for each column. It differs 40 | if \code{alt_counts_df} is used (see \code{\link[=build_table]{build_table()}}).} 41 | } 42 | } 43 | \note{ 44 | If any of these formals is specified incorrectly or not present in the tabulation machinery, it will be 45 | treated as if missing. For example, \code{.ref_group} will be missing if no baseline is previously defined during 46 | data splitting (via \code{ref_group} parameters in, e.g., \code{\link[=split_rows_by]{split_rows_by()}}). Similarly, if no \code{alt_counts_df} is 47 | provided to \code{\link[=build_table]{build_table()}}, \code{.alt_df_row} and \code{.alt_df} will not be present. 48 | } 49 | -------------------------------------------------------------------------------- /man/append_topleft.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{append_topleft} 4 | \alias{append_topleft} 5 | \title{Append a description to the 'top-left' materials for the layout} 6 | \usage{ 7 | append_topleft(lyt, newlines) 8 | } 9 | \arguments{ 10 | \item{lyt}{(\code{PreDataTableLayouts})\cr layout object pre-data used for tabulation.} 11 | 12 | \item{newlines}{(\code{character})\cr the new line(s) to be added to the materials.} 13 | } 14 | \value{ 15 | A \code{PreDataTableLayouts} object suitable for passing to further layouting functions, and to \code{\link[=build_table]{build_table()}}. 16 | } 17 | \description{ 18 | This function \emph{adds} \code{newlines} to the current set of "top-left materials". 19 | } 20 | \details{ 21 | Adds \code{newlines} to the set of strings representing the 'top-left' materials declared in the layout (the content 22 | displayed to the left of the column labels when the resulting tables are printed). 23 | 24 | Top-left material strings are stored and then displayed \emph{exactly as is}, no structure or indenting is applied to 25 | them either when they are added or when they are displayed. 26 | } 27 | \note{ 28 | Currently, where in the construction of the layout this is called makes no difference, as it is independent of 29 | the actual splitting keywords. This may change in the future. 30 | 31 | This function is experimental, its name and the details of its behavior are subject to change in future versions. 32 | } 33 | \examples{ 34 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 35 | library(dplyr) 36 | 37 | DM2 <- DM \%>\% mutate(RACE = factor(RACE), SEX = factor(SEX)) 38 | 39 | lyt <- basic_table() \%>\% 40 | split_cols_by("ARM") \%>\% 41 | split_cols_by("SEX") \%>\% 42 | split_rows_by("RACE") \%>\% 43 | append_topleft("Ethnicity") \%>\% 44 | analyze("AGE") \%>\% 45 | append_topleft(" Age") 46 | 47 | tbl <- build_table(lyt, DM2) 48 | tbl 49 | \dontshow{\}) # examplesIf} 50 | } 51 | \seealso{ 52 | \code{\link[=top_left]{top_left()}} 53 | } 54 | -------------------------------------------------------------------------------- /man/as_html.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/as_html.R 3 | \name{as_html} 4 | \alias{as_html} 5 | \title{Convert an \code{rtable} object to a \code{shiny.tag} HTML object} 6 | \usage{ 7 | as_html( 8 | x, 9 | width = NULL, 10 | class_table = "table table-condensed table-hover", 11 | class_tr = NULL, 12 | class_th = NULL, 13 | link_label = NULL, 14 | bold = c("header"), 15 | header_sep_line = TRUE, 16 | no_spaces_between_cells = FALSE, 17 | expand_newlines = FALSE 18 | ) 19 | } 20 | \arguments{ 21 | \item{x}{(\code{VTableTree})\cr a \code{TableTree} object.} 22 | 23 | \item{width}{(\code{character})\cr a string to indicate the desired width of the table. Common input formats include a 24 | percentage of the viewer window width (e.g. \code{"100\%"}) or a distance value (e.g. \code{"300px"}). Defaults to \code{NULL}.} 25 | 26 | \item{class_table}{(\code{character})\cr class for \code{table} tag.} 27 | 28 | \item{class_tr}{(\code{character})\cr class for \code{tr} tag.} 29 | 30 | \item{class_th}{(\code{character})\cr class for \code{th} tag.} 31 | 32 | \item{link_label}{(\code{character})\cr link anchor label (not including \verb{tab:} prefix) for the table.} 33 | 34 | \item{bold}{(\code{character})\cr elements in table output that should be bold. Options are \code{"main_title"}, 35 | \code{"subtitles"}, \code{"header"}, \code{"row_names"}, \code{"label_rows"}, and \code{"content_rows"} (which includes any non-label 36 | rows). Defaults to \code{"header"}.} 37 | 38 | \item{header_sep_line}{(\code{flag})\cr whether a black line should be printed to under the table header. Defaults 39 | to \code{TRUE}.} 40 | 41 | \item{no_spaces_between_cells}{(\code{flag})\cr whether spaces between table cells should be collapsed. Defaults 42 | to \code{FALSE}.} 43 | 44 | \item{expand_newlines}{(\code{flag})\cr Defaults to \code{FALSE}, relying on \code{html} output to solve newline characters (\verb{\\n}). 45 | Doing this keeps the structure of the cells but may depend on the output device.} 46 | } 47 | \value{ 48 | A \code{shiny.tag} object representing \code{x} in HTML. 49 | } 50 | \description{ 51 | The returned HTML object can be immediately used in \code{shiny} and \code{rmarkdown}. 52 | } 53 | \examples{ 54 | tbl <- rtable( 55 | header = LETTERS[1:3], 56 | format = "xx", 57 | rrow("r1", 1, 2, 3), 58 | rrow("r2", 4, 3, 2, indent = 1), 59 | rrow("r3", indent = 2) 60 | ) 61 | 62 | as_html(tbl) 63 | 64 | as_html(tbl, class_table = "table", class_tr = "row") 65 | 66 | as_html(tbl, bold = c("header", "row_names")) 67 | 68 | \dontrun{ 69 | Viewer(tbl) 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /man/asvec.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{asvec} 4 | \alias{asvec} 5 | \alias{as.vector,VTableTree-method} 6 | \title{Convert to a vector} 7 | \usage{ 8 | \S4method{as.vector}{VTableTree}(x, mode = "any") 9 | } 10 | \arguments{ 11 | \item{x}{(\code{ANY})\cr the object to be converted to a vector.} 12 | 13 | \item{mode}{(\code{string})\cr passed on to \code{\link[=as.vector]{as.vector()}}.} 14 | } 15 | \value{ 16 | A vector of the chosen mode (or an error is raised if more than one row was present). 17 | } 18 | \description{ 19 | Convert an \code{rtables} framework object into a vector, if possible. This is unlikely to be useful in 20 | realistic scenarios. 21 | } 22 | \note{ 23 | This only works for a table with a single row or a row object. 24 | } 25 | -------------------------------------------------------------------------------- /man/cbind_rtables.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compatibility.R 3 | \name{cbind_rtables} 4 | \alias{cbind_rtables} 5 | \title{Column-bind two \code{TableTree} objects} 6 | \usage{ 7 | cbind_rtables(x, ..., sync_count_vis = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{TableTree} or \code{TableRow})\cr a table or row object.} 11 | 12 | \item{...}{one or more further objects of the same class as \code{x}.} 13 | 14 | \item{sync_count_vis}{(\code{logical(1)})\cr should column count 15 | visibility be synced across the new and existing columns. 16 | Currently defaults to \code{TRUE} for backwards compatibility but 17 | this may change in future releases.} 18 | } 19 | \value{ 20 | A formal table object. 21 | } 22 | \description{ 23 | Column-bind two \code{TableTree} objects 24 | } 25 | \examples{ 26 | x <- rtable(c("A", "B"), rrow("row 1", 1, 2), rrow("row 2", 3, 4)) 27 | y <- rtable("C", rrow("row 1", 5), rrow("row 2", 6)) 28 | z <- rtable("D", rrow("row 1", 9), rrow("row 2", 10)) 29 | 30 | t1 <- cbind_rtables(x, y) 31 | t1 32 | 33 | t2 <- cbind_rtables(x, y, z) 34 | t2 35 | 36 | col_paths_summary(t1) 37 | col_paths_summary(t2) 38 | 39 | } 40 | -------------------------------------------------------------------------------- /man/cell_values.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_pos_and_access.R 3 | \name{cell_values} 4 | \alias{cell_values} 5 | \alias{value_at} 6 | \alias{value_at,VTableTree-method} 7 | \title{Retrieve cell values by row and column path} 8 | \usage{ 9 | cell_values(tt, rowpath = NULL, colpath = NULL, omit_labrows = TRUE) 10 | 11 | value_at(tt, rowpath = NULL, colpath = NULL) 12 | 13 | \S4method{value_at}{VTableTree}(tt, rowpath = NULL, colpath = NULL) 14 | } 15 | \arguments{ 16 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 17 | 18 | \item{rowpath}{(\code{character})\cr path in row-split space to the desired row(s). Can include \code{"@content"}.} 19 | 20 | \item{colpath}{(\code{character})\cr path in column-split space to the desired column(s). Can include \code{"*"}.} 21 | 22 | \item{omit_labrows}{(\code{flag})\cr whether label rows underneath \code{rowpath} should be omitted (\code{TRUE}, the default), 23 | or return empty lists of cell "values" (\code{FALSE}).} 24 | } 25 | \value{ 26 | \itemize{ 27 | \item \code{cell_values} returns a \code{list} (regardless of the type of value the cells hold). If \code{rowpath} defines a path to 28 | a single row, \code{cell_values} returns the list of cell values for that row, otherwise a list of such lists, one for 29 | each row captured underneath \code{rowpath}. This occurs after subsetting to \code{colpath} has occurred. 30 | \item \code{value_at} returns the "unwrapped" value of a single cell, or an error, if the combination of \code{rowpath} and 31 | \code{colpath} do not define the location of a single cell in \code{tt}. 32 | } 33 | } 34 | \description{ 35 | Retrieve cell values by row and column path 36 | } 37 | \note{ 38 | \code{cell_values} will return a single cell's value wrapped in a list. Use \code{value_at} to receive the "bare" cell 39 | value. 40 | } 41 | \examples{ 42 | lyt <- basic_table() \%>\% 43 | split_cols_by("ARM") \%>\% 44 | split_cols_by("SEX") \%>\% 45 | split_rows_by("RACE") \%>\% 46 | summarize_row_groups() \%>\% 47 | split_rows_by("STRATA1") \%>\% 48 | analyze("AGE") 49 | 50 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 51 | library(dplyr) ## for mutate 52 | tbl <- build_table(lyt, DM \%>\% 53 | mutate(SEX = droplevels(SEX), RACE = droplevels(RACE))) 54 | 55 | row_paths_summary(tbl) 56 | col_paths_summary(tbl) 57 | 58 | cell_values( 59 | tbl, c("RACE", "ASIAN", "STRATA1", "B"), 60 | c("ARM", "A: Drug X", "SEX", "F") 61 | ) 62 | 63 | # it's also possible to access multiple values by being less specific 64 | cell_values( 65 | tbl, c("RACE", "ASIAN", "STRATA1"), 66 | c("ARM", "A: Drug X", "SEX", "F") 67 | ) 68 | cell_values(tbl, c("RACE", "ASIAN"), c("ARM", "A: Drug X", "SEX", "M")) 69 | 70 | ## any arm, male columns from the ASIAN content (i.e. summary) row 71 | cell_values( 72 | tbl, c("RACE", "ASIAN", "@content"), 73 | c("ARM", "B: Placebo", "SEX", "M") 74 | ) 75 | cell_values( 76 | tbl, c("RACE", "ASIAN", "@content"), 77 | c("ARM", "*", "SEX", "M") 78 | ) 79 | 80 | ## all columns 81 | cell_values(tbl, c("RACE", "ASIAN", "STRATA1", "B")) 82 | 83 | ## all columns for the Combination arm 84 | cell_values( 85 | tbl, c("RACE", "ASIAN", "STRATA1", "B"), 86 | c("ARM", "C: Combination") 87 | ) 88 | 89 | cvlist <- cell_values( 90 | tbl, c("RACE", "ASIAN", "STRATA1", "B", "AGE", "Mean"), 91 | c("ARM", "B: Placebo", "SEX", "M") 92 | ) 93 | cvnolist <- value_at( 94 | tbl, c("RACE", "ASIAN", "STRATA1", "B", "AGE", "Mean"), 95 | c("ARM", "B: Placebo", "SEX", "M") 96 | ) 97 | stopifnot(identical(cvlist[[1]], cvnolist)) 98 | \dontshow{\}) # examplesIf} 99 | } 100 | -------------------------------------------------------------------------------- /man/cinfo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00tabletrees.R 3 | \docType{class} 4 | \name{InstantiatedColumnInfo-class} 5 | \alias{InstantiatedColumnInfo-class} 6 | \alias{InstantiatedColumnInfo} 7 | \title{Instantiated column info} 8 | \usage{ 9 | InstantiatedColumnInfo( 10 | treelyt = LayoutColTree(colcount = total_cnt), 11 | csubs = list(expression(TRUE)), 12 | extras = list(list()), 13 | cnts = NA_integer_, 14 | total_cnt = NA_integer_, 15 | dispcounts = FALSE, 16 | countformat = "(N=xx)", 17 | count_na_str = "", 18 | topleft = character() 19 | ) 20 | } 21 | \arguments{ 22 | \item{treelyt}{(\code{LayoutColTree})\cr a \code{LayoutColTree} object.} 23 | 24 | \item{csubs}{(\code{list})\cr a list of subsetting expressions.} 25 | 26 | \item{extras}{(\code{list})\cr extra arguments associated with the columns.} 27 | 28 | \item{cnts}{(\code{integer})\cr counts.} 29 | 30 | \item{total_cnt}{(\code{integer(1)})\cr total observations represented across all columns.} 31 | 32 | \item{dispcounts}{(\code{flag})\cr whether the counts should be displayed as header info when the associated 33 | table is printed.} 34 | 35 | \item{countformat}{(\code{string})\cr format for the counts if they are displayed.} 36 | 37 | \item{count_na_str}{(\code{character})\cr string to use in place of missing values when formatting counts. Defaults 38 | to \code{""}.} 39 | 40 | \item{topleft}{(\code{character})\cr override values for the "top left" material to be displayed during printing.} 41 | } 42 | \value{ 43 | An \code{InstantiateadColumnInfo} object. 44 | } 45 | \description{ 46 | Instantiated column info 47 | } 48 | -------------------------------------------------------------------------------- /man/clear_imods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/indent.R 3 | \name{clear_indent_mods} 4 | \alias{clear_indent_mods} 5 | \alias{clear_indent_mods,VTableTree-method} 6 | \alias{clear_indent_mods,TableRow-method} 7 | \title{Clear all indent modifiers from a table} 8 | \usage{ 9 | clear_indent_mods(tt) 10 | 11 | \S4method{clear_indent_mods}{VTableTree}(tt) 12 | 13 | \S4method{clear_indent_mods}{TableRow}(tt) 14 | } 15 | \arguments{ 16 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 17 | } 18 | \value{ 19 | The same class as \code{tt}, with all indent modifiers set to zero. 20 | } 21 | \description{ 22 | Clear all indent modifiers from a table 23 | } 24 | \examples{ 25 | lyt1 <- basic_table() \%>\% 26 | summarize_row_groups("STUDYID", label_fstr = "overall summary") \%>\% 27 | split_rows_by("AEBODSYS", child_labels = "visible") \%>\% 28 | summarize_row_groups("STUDYID", label_fstr = "subgroup summary") \%>\% 29 | analyze("AGE", indent_mod = -1L) 30 | 31 | tbl1 <- build_table(lyt1, ex_adae) 32 | tbl1 33 | clear_indent_mods(tbl1) 34 | 35 | } 36 | -------------------------------------------------------------------------------- /man/colcount_visible.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{colcount_visible} 4 | \alias{colcount_visible} 5 | \alias{colcount_visible,VTableTree-method} 6 | \alias{colcount_visible,InstantiatedColumnInfo-method} 7 | \alias{colcount_visible,LayoutColTree-method} 8 | \alias{colcount_visible<-} 9 | \alias{colcount_visible<-,VTableTree-method} 10 | \alias{colcount_visible<-,InstantiatedColumnInfo-method} 11 | \alias{colcount_visible<-,LayoutColTree-method} 12 | \title{Value and Visibility of specific column counts by path} 13 | \usage{ 14 | colcount_visible(obj, path) 15 | 16 | \S4method{colcount_visible}{VTableTree}(obj, path) 17 | 18 | \S4method{colcount_visible}{InstantiatedColumnInfo}(obj, path) 19 | 20 | \S4method{colcount_visible}{LayoutColTree}(obj, path) 21 | 22 | colcount_visible(obj, path) <- value 23 | 24 | \S4method{colcount_visible}{VTableTree}(obj, path) <- value 25 | 26 | \S4method{colcount_visible}{InstantiatedColumnInfo}(obj, path) <- value 27 | 28 | \S4method{colcount_visible}{LayoutColTree}(obj, path) <- value 29 | } 30 | \arguments{ 31 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 32 | 33 | \item{path}{(\code{character})\cr a vector path for a position within the structure of a \code{TableTree}. Each element 34 | represents a subsequent choice amongst the children of the previous choice.} 35 | 36 | \item{value}{(\code{ANY})\cr the new value.} 37 | } 38 | \value{ 39 | for \code{colcount_visible} a logical scalar 40 | indicating whether the specified position in 41 | the column hierarchy is set to display its column count; 42 | for \verb{colcount_visible<-}, \code{obj} updated with 43 | the specified count displaying behavior set. 44 | } 45 | \description{ 46 | Value and Visibility of specific column counts by path 47 | } 48 | \note{ 49 | Users generally should not call \code{colcount_visible} 50 | directly, as setting sibling facets to have differing 51 | column count visibility will result in an error when 52 | printing or paginating the table. 53 | } 54 | -------------------------------------------------------------------------------- /man/collect_leaves.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{collect_leaves} 4 | \alias{collect_leaves} 5 | \title{Collect leaves of a \code{TableTree}} 6 | \usage{ 7 | collect_leaves(tt, incl.cont = TRUE, add.labrows = FALSE) 8 | } 9 | \arguments{ 10 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 11 | 12 | \item{incl.cont}{(\code{flag})\cr whether to include rows from content tables within the tree. Defaults to \code{TRUE}.} 13 | 14 | \item{add.labrows}{(\code{flag})\cr whether to include label rows. Defaults to \code{FALSE}.} 15 | } 16 | \value{ 17 | A list of \code{TableRow} objects for all rows in the table. 18 | } 19 | \description{ 20 | Collect leaves of a \code{TableTree} 21 | } 22 | -------------------------------------------------------------------------------- /man/coltree_structure.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_showmethods.R 3 | \name{coltree_structure} 4 | \alias{coltree_structure} 5 | \title{Display column tree structure} 6 | \usage{ 7 | coltree_structure(obj) 8 | } 9 | \arguments{ 10 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 11 | } 12 | \value{ 13 | Nothing, called for its side effect of displaying 14 | a summary to the terminal. 15 | } 16 | \description{ 17 | Displays the tree structure of the columns of a 18 | table or column structure object. 19 | } 20 | \examples{ 21 | lyt <- basic_table() \%>\% 22 | split_cols_by("ARM") \%>\% 23 | split_cols_by("STRATA1") \%>\% 24 | split_cols_by("SEX", nested = FALSE) \%>\% 25 | analyze("AGE") 26 | 27 | tbl <- build_table(lyt, ex_adsl) 28 | coltree_structure(tbl) 29 | } 30 | -------------------------------------------------------------------------------- /man/compare_rtables.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/compare_rtables.R 3 | \name{compare_rtables} 4 | \alias{compare_rtables} 5 | \title{Compare two rtables} 6 | \usage{ 7 | compare_rtables( 8 | object, 9 | expected, 10 | tol = 0.1, 11 | comp.attr = TRUE, 12 | structure = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{object}{(\code{VTableTree})\cr \code{rtable} to test.} 17 | 18 | \item{expected}{(\code{VTableTree})\cr expected \code{rtable}.} 19 | 20 | \item{tol}{(\code{numeric(1)})\cr tolerance.} 21 | 22 | \item{comp.attr}{(\code{flag})\cr whether to compare cell formats. Other attributes are 23 | silently ignored.} 24 | 25 | \item{structure}{(\code{flag})\cr whether structures (in the form of column and row 26 | paths to cells) should be compared. Currently defaults to \code{FALSE}, but this is 27 | subject to change in future versions.} 28 | } 29 | \value{ 30 | A matrix of class \code{rtables_diff} representing the differences 31 | between \code{object} and \code{expected} as described above. 32 | } 33 | \description{ 34 | Prints a matrix where \code{.} means cell matches, \code{X} means cell does 35 | not match, \code{+} cell (row) is missing, and \code{-} cell (row) 36 | should not be there. If \code{structure} is set to \code{TRUE}, \code{C} indicates 37 | column-structure mismatch, \code{R} indicates row-structure mismatch, and 38 | \code{S} indicates mismatch in both row and column structure. 39 | } 40 | \note{ 41 | In its current form, \code{compare_rtables} does not take structure into 42 | account, only row and cell position. 43 | } 44 | \examples{ 45 | t1 <- rtable(header = c("A", "B"), format = "xx", rrow("row 1", 1, 2)) 46 | t2 <- rtable(header = c("A", "B", "C"), format = "xx", rrow("row 1", 1, 2, 3)) 47 | 48 | compare_rtables(object = t1, expected = t2) 49 | 50 | if (interactive()) { 51 | Viewer(t1, t2) 52 | } 53 | 54 | expected <- rtable( 55 | header = c("ARM A\nN=100", "ARM B\nN=200"), 56 | format = "xx", 57 | rrow("row 1", 10, 15), 58 | rrow(), 59 | rrow("section title"), 60 | rrow("row colspan", rcell(c(.345543, .4432423), colspan = 2, format = "(xx.xx, xx.xx)")) 61 | ) 62 | 63 | expected 64 | 65 | object <- rtable( 66 | header = c("ARM A\nN=100", "ARM B\nN=200"), 67 | format = "xx", 68 | rrow("row 1", 10, 15), 69 | rrow("section title"), 70 | rrow("row colspan", rcell(c(.345543, .4432423), colspan = 2, format = "(xx.xx, xx.xx)")) 71 | ) 72 | 73 | compare_rtables(object, expected, comp.attr = FALSE) 74 | 75 | object <- rtable( 76 | header = c("ARM A\nN=100", "ARM B\nN=200"), 77 | format = "xx", 78 | rrow("row 1", 10, 15), 79 | rrow(), 80 | rrow("section title") 81 | ) 82 | 83 | compare_rtables(object, expected) 84 | 85 | object <- rtable( 86 | header = c("ARM A\nN=100", "ARM B\nN=200"), 87 | format = "xx", 88 | rrow("row 1", 14, 15.03), 89 | rrow(), 90 | rrow("section title"), 91 | rrow("row colspan", rcell(c(.345543, .4432423), colspan = 2, format = "(xx.xx, xx.xx)")) 92 | ) 93 | 94 | compare_rtables(object, expected) 95 | 96 | object <- rtable( 97 | header = c("ARM A\nN=100", "ARM B\nN=200"), 98 | format = "xx", 99 | rrow("row 1", 10, 15), 100 | rrow(), 101 | rrow("section title"), 102 | rrow("row colspan", rcell(c(.345543, .4432423), colspan = 2, format = "(xx.x, xx.x)")) 103 | ) 104 | 105 | compare_rtables(object, expected) 106 | 107 | } 108 | -------------------------------------------------------------------------------- /man/compat_args.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/argument_conventions.R 3 | \name{compat_args} 4 | \alias{compat_args} 5 | \title{Compatibility argument conventions} 6 | \usage{ 7 | compat_args(.lst, row.name, format, indent, label, inset) 8 | } 9 | \arguments{ 10 | \item{.lst}{(\code{list})\cr an already-collected list of arguments to be used instead of the elements of \code{...}. 11 | Arguments passed via \code{...} will be ignored if this is specified.} 12 | 13 | \item{row.name}{(\code{string} or \code{NULL})\cr row name. If \code{NULL}, an empty string is used as \code{row.name} of the 14 | \code{\link[=rrow]{rrow()}}.} 15 | 16 | \item{format}{(\code{string}, \code{function}, or \code{list})\cr the format label (string) or formatter function to apply to the 17 | cell values passed via \code{...}. See \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for currently supported format labels.} 18 | 19 | \item{indent}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}} 20 | 21 | \item{label}{(\code{string})\cr a label (not to be confused with the name) for the object/structure.} 22 | 23 | \item{inset}{(\code{integer(1)})\cr the table inset for the row or table being constructed. See 24 | \code{\link[formatters:table_inset]{formatters::table_inset()}} for details.} 25 | } 26 | \value{ 27 | No return value. 28 | } 29 | \description{ 30 | Compatibility argument conventions 31 | } 32 | \seealso{ 33 | Other conventions: 34 | \code{\link{constr_args}()}, 35 | \code{\link{gen_args}()}, 36 | \code{\link{lyt_args}()}, 37 | \code{\link{sf_args}()} 38 | } 39 | \concept{conventions} 40 | -------------------------------------------------------------------------------- /man/content_table.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{content_table} 4 | \alias{content_table} 5 | \alias{content_table<-} 6 | \title{Retrieve or set content table from a \code{TableTree}} 7 | \usage{ 8 | content_table(obj) 9 | 10 | content_table(obj) <- value 11 | } 12 | \arguments{ 13 | \item{obj}{(\code{TableTree})\cr the table object.} 14 | 15 | \item{value}{(\code{ElementaryTable})\cr the new content table for \code{obj}.} 16 | } 17 | \value{ 18 | the \code{ElementaryTable} containing the (top level) \emph{content rows} of \code{obj} (or \code{NULL} if \code{obj} is not 19 | a formal table object). 20 | } 21 | \description{ 22 | Returns the content table of \code{obj} if it is a \code{TableTree} object, or \code{NULL} otherwise. 23 | } 24 | -------------------------------------------------------------------------------- /man/counts_wpcts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{counts_wpcts} 4 | \alias{counts_wpcts} 5 | \title{Analysis function to count levels of a factor with percentage of the column total} 6 | \usage{ 7 | counts_wpcts(x, .N_col) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{factor})\cr a vector of data, provided by rtables pagination machinery.} 11 | 12 | \item{.N_col}{(\code{integer(1)})\cr total count for the column, provided by rtables pagination machinery.} 13 | } 14 | \value{ 15 | A \code{RowsVerticalSection} object with counts (and percents) for each level of the factor. 16 | } 17 | \description{ 18 | Analysis function to count levels of a factor with percentage of the column total 19 | } 20 | \examples{ 21 | counts_wpcts(DM$SEX, 400) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /man/df_to_tt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_from_df.R 3 | \name{df_to_tt} 4 | \alias{df_to_tt} 5 | \title{Create an \code{ElementaryTable} from a \code{data.frame}} 6 | \usage{ 7 | df_to_tt(df) 8 | } 9 | \arguments{ 10 | \item{df}{(\code{data.frame})\cr a data frame.} 11 | } 12 | \description{ 13 | Create an \code{ElementaryTable} from a \code{data.frame} 14 | } 15 | \details{ 16 | If row names are not defined in \code{df} (or they are simple numbers), then the row names are taken from the column 17 | \code{label_name}, if it exists. If \code{label_name} exists, then it is also removed from the original data. This behavior 18 | is compatible with \code{\link[=as_result_df]{as_result_df()}}, when \code{as_is = TRUE} and the row names are not unique. 19 | } 20 | \examples{ 21 | df_to_tt(mtcars) 22 | 23 | } 24 | \seealso{ 25 | \code{\link[=as_result_df]{as_result_df()}} for the inverse operation. 26 | } 27 | -------------------------------------------------------------------------------- /man/dimensions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{nrow,VTableTree-method} 4 | \alias{nrow,VTableTree-method} 5 | \alias{ncol,VTableNodeInfo-method} 6 | \alias{dim,VTableNodeInfo-method} 7 | \title{Table dimensions} 8 | \usage{ 9 | \S4method{nrow}{VTableTree}(x) 10 | 11 | \S4method{ncol}{VTableNodeInfo}(x) 12 | 13 | \S4method{dim}{VTableNodeInfo}(x) 14 | } 15 | \arguments{ 16 | \item{x}{(\code{TableTree} or \code{ElementaryTable})\cr a table object.} 17 | } 18 | \value{ 19 | The number of rows (\code{nrow}), columns (\code{ncol}), or both (\code{dim}) of the object. 20 | } 21 | \description{ 22 | Table dimensions 23 | } 24 | \examples{ 25 | lyt <- basic_table() \%>\% 26 | split_cols_by("ARM") \%>\% 27 | analyze(c("SEX", "AGE")) 28 | 29 | tbl <- build_table(lyt, ex_adsl) 30 | 31 | dim(tbl) 32 | nrow(tbl) 33 | ncol(tbl) 34 | 35 | NROW(tbl) 36 | NCOL(tbl) 37 | 38 | } 39 | -------------------------------------------------------------------------------- /man/do_base_split.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/custom_split_funs.R 3 | \name{do_base_split} 4 | \alias{do_base_split} 5 | \title{Apply basic split (for use in custom split functions)} 6 | \usage{ 7 | do_base_split(spl, df, vals = NULL, labels = NULL, trim = FALSE) 8 | } 9 | \arguments{ 10 | \item{spl}{(\code{Split})\cr a \code{Split} object defining a partitioning or analysis/tabulation of the data.} 11 | 12 | \item{df}{(\code{data.frame} or \code{tibble})\cr dataset.} 13 | 14 | \item{vals}{(\code{ANY})\cr already calculated/known values of the split. Generally should be left as \code{NULL}.} 15 | 16 | \item{labels}{(\code{character})\cr labels associated with \code{vals}. Should be \code{NULL} whenever \code{vals} is, which should 17 | almost always be the case.} 18 | 19 | \item{trim}{(\code{flag})\cr whether groups corresponding to empty data subsets should be removed. Defaults to 20 | \code{FALSE}.} 21 | } 22 | \value{ 23 | The result of the split being applied as if it had no custom split function. See \link{custom_split_funs}. 24 | } 25 | \description{ 26 | This function is intended for use inside custom split functions. It applies the current split \emph{as if it had no 27 | custom splitting function} so that those default splits can be further manipulated. 28 | } 29 | \examples{ 30 | uneven_splfun <- function(df, spl, vals = NULL, labels = NULL, trim = FALSE) { 31 | ret <- do_base_split(spl, df, vals, labels, trim) 32 | if (NROW(df) == 0) { 33 | ret <- lapply(ret, function(x) x[1]) 34 | } 35 | ret 36 | } 37 | 38 | lyt <- basic_table() \%>\% 39 | split_cols_by("ARM") \%>\% 40 | split_cols_by_multivar(c("USUBJID", "AESEQ", "BMRKR1"), 41 | varlabels = c("N", "E", "BMR1"), 42 | split_fun = uneven_splfun 43 | ) \%>\% 44 | analyze_colvars(list( 45 | USUBJID = function(x, ...) length(unique(x)), 46 | AESEQ = max, 47 | BMRKR1 = mean 48 | )) 49 | 50 | tbl <- build_table(lyt, subset(ex_adae, as.numeric(ARM) <= 2)) 51 | tbl 52 | 53 | } 54 | -------------------------------------------------------------------------------- /man/drop_facet_levels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/make_split_fun.R 3 | \name{drop_facet_levels} 4 | \alias{drop_facet_levels} 5 | \title{Pre-processing function for use in \code{make_split_fun}} 6 | \usage{ 7 | drop_facet_levels(df, spl, ...) 8 | } 9 | \arguments{ 10 | \item{df}{(\code{data.frame})\cr the incoming data corresponding with the parent facet.} 11 | 12 | \item{spl}{(\code{VarLevelSplit})\cr the split.} 13 | 14 | \item{...}{additional parameters passed internally.} 15 | } 16 | \description{ 17 | This function is intended for use as a pre-processing component in \code{make_split_fun}, and should not be called 18 | directly by end users. 19 | } 20 | \seealso{ 21 | \code{\link[=make_split_fun]{make_split_fun()}} 22 | 23 | Other make_custom_split: 24 | \code{\link{add_combo_facet}()}, 25 | \code{\link{make_split_fun}()}, 26 | \code{\link{make_split_result}()}, 27 | \code{\link{trim_levels_in_facets}()} 28 | } 29 | \concept{make_custom_split} 30 | -------------------------------------------------------------------------------- /man/facet_colcount.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{facet_colcount} 4 | \alias{facet_colcount} 5 | \alias{facet_colcount,LayoutColTree-method} 6 | \alias{facet_colcount,LayoutColLeaf-method} 7 | \alias{facet_colcount,VTableTree-method} 8 | \alias{facet_colcount,InstantiatedColumnInfo-method} 9 | \alias{facet_colcount<-} 10 | \alias{facet_colcount<-,LayoutColTree-method} 11 | \alias{facet_colcount<-,LayoutColLeaf-method} 12 | \alias{facet_colcount<-,VTableTree-method} 13 | \alias{facet_colcount<-,InstantiatedColumnInfo-method} 14 | \title{Get or set column count for a facet in column space} 15 | \usage{ 16 | facet_colcount(obj, path) 17 | 18 | \S4method{facet_colcount}{LayoutColTree}(obj, path = NULL) 19 | 20 | \S4method{facet_colcount}{LayoutColLeaf}(obj, path = NULL) 21 | 22 | \S4method{facet_colcount}{VTableTree}(obj, path) 23 | 24 | \S4method{facet_colcount}{InstantiatedColumnInfo}(obj, path) 25 | 26 | facet_colcount(obj, path) <- value 27 | 28 | \S4method{facet_colcount}{LayoutColTree}(obj, path) <- value 29 | 30 | \S4method{facet_colcount}{LayoutColLeaf}(obj, path) <- value 31 | 32 | \S4method{facet_colcount}{VTableTree}(obj, path) <- value 33 | 34 | \S4method{facet_colcount}{InstantiatedColumnInfo}(obj, path) <- value 35 | } 36 | \arguments{ 37 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 38 | 39 | \item{path}{character. This path must end on a 40 | split value, e.g., the level of a categorical variable 41 | that was split on in column space, but it need not 42 | be the path to an individual column.} 43 | 44 | \item{value}{(\code{ANY})\cr the new value.} 45 | } 46 | \value{ 47 | for \code{facet_colcount} the current count associated 48 | with that facet in column space, for \verb{facet_colcount<-}, 49 | \code{obj} modified with the new column count for the specified 50 | facet. 51 | } 52 | \description{ 53 | Get or set column count for a facet in column space 54 | } 55 | \note{ 56 | Updating a lower-level (more specific) 57 | column count manually \strong{will not} update the 58 | counts for its parent facets. This cannot be made 59 | automatic because the rtables framework does not 60 | require sibling facets to be mutually exclusive 61 | (e.g., total "arm", faceting into cumulative 62 | quantiles, etc) and thus the count of a parent facet 63 | will not always be simply the sum of the counts for 64 | all of its children. 65 | } 66 | \examples{ 67 | lyt <- basic_table() \%>\% 68 | split_cols_by("ARM", show_colcounts = TRUE) \%>\% 69 | split_cols_by("SEX", 70 | split_fun = keep_split_levels(c("F", "M")), 71 | show_colcounts = TRUE 72 | ) \%>\% 73 | split_cols_by("STRATA1", show_colcounts = TRUE) \%>\% 74 | analyze("AGE") 75 | 76 | tbl <- build_table(lyt, ex_adsl) 77 | 78 | facet_colcount(tbl, c("ARM", "A: Drug X")) 79 | facet_colcount(tbl, c("ARM", "A: Drug X", "SEX", "F")) 80 | facet_colcount(tbl, c("ARM", "A: Drug X", "SEX", "F", "STRATA1", "A")) 81 | 82 | ## modify specific count after table creation 83 | facet_colcount(tbl, c("ARM", "A: Drug X", "SEX", "F", "STRATA1", "A")) <- 25 84 | 85 | ## show black space for certain counts by assign NA 86 | 87 | facet_colcount(tbl, c("ARM", "A: Drug X", "SEX", "F", "STRATA1", "C")) <- NA 88 | 89 | } 90 | \seealso{ 91 | \code{\link[=col_counts]{col_counts()}} 92 | } 93 | -------------------------------------------------------------------------------- /man/facet_colcounts_visible-set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{facet_colcounts_visible<-} 4 | \alias{facet_colcounts_visible<-} 5 | \title{Set visibility of column counts for a group of sibling facets} 6 | \usage{ 7 | facet_colcounts_visible(obj, path) <- value 8 | } 9 | \arguments{ 10 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 11 | 12 | \item{path}{(\code{character})\cr the path \emph{to the parent of the 13 | desired siblings}. The last element in the path should 14 | be a split name.} 15 | 16 | \item{value}{(\code{ANY})\cr the new value.} 17 | } 18 | \value{ 19 | obj, modified with the desired column count. 20 | display behavior 21 | } 22 | \description{ 23 | Set visibility of column counts for a group of sibling facets 24 | } 25 | \seealso{ 26 | \code{\link[=colcount_visible]{colcount_visible()}} 27 | } 28 | -------------------------------------------------------------------------------- /man/figures/lifecycle-archived.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: archived 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | archived 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-defunct.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: defunct 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | defunct 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-deprecated.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: deprecated 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | deprecated 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-experimental.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: experimental 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | experimental 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-maturing.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: maturing 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | maturing 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-questioning.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: questioning 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | questioning 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-soft-deprecated.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: soft-deprecated 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | soft-deprecated 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/figures/lifecycle-stable.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: stable 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | lifecycle 21 | 22 | 25 | 26 | stable 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /man/figures/lifecycle-superseded.svg: -------------------------------------------------------------------------------- 1 | 2 | lifecycle: superseded 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | lifecycle 18 | 19 | superseded 20 | 21 | 22 | -------------------------------------------------------------------------------- /man/find_degen_struct.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/validate_table_struct.R 3 | \name{find_degen_struct} 4 | \alias{find_degen_struct} 5 | \title{Find degenerate (sub)structures within a table} 6 | \usage{ 7 | find_degen_struct(tt) 8 | } 9 | \arguments{ 10 | \item{tt}{(\code{TableTree})\cr a \code{TableTree} object.} 11 | } 12 | \value{ 13 | A list of character vectors representing the row paths, if any, to degenerate substructures within the table. 14 | } 15 | \description{ 16 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} 17 | 18 | This function returns a list with the row-paths to all structural subtables which contain no data rows (even if 19 | they have associated content rows). 20 | } 21 | \examples{ 22 | find_degen_struct(rtable("hi")) 23 | 24 | } 25 | \seealso{ 26 | Other table structure validation functions: 27 | \code{\link{sanitize_table_struct}()}, 28 | \code{\link{validate_table_struct}()} 29 | } 30 | \concept{table structure validation functions} 31 | -------------------------------------------------------------------------------- /man/format_rcell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/format_rcell.R 3 | \name{format_rcell} 4 | \alias{format_rcell} 5 | \title{Format \code{rcell} objects} 6 | \usage{ 7 | format_rcell( 8 | x, 9 | format, 10 | output = c("ascii", "html"), 11 | na_str = obj_na_str(x) \%||\% "NA", 12 | pr_row_format = NULL, 13 | pr_row_na_str = NULL, 14 | round_type = c("iec", "sas"), 15 | shell = FALSE 16 | ) 17 | } 18 | \arguments{ 19 | \item{x}{(\code{CellValue} or \code{ANY})\cr an object of class \code{CellValue}, or a raw value.} 20 | 21 | \item{format}{(\code{string} or \code{function})\cr the format label or formatter function to 22 | apply to \code{x}.} 23 | 24 | \item{output}{(\code{string})\cr output type.} 25 | 26 | \item{na_str}{(\code{string})\cr string that should be displayed when the value of \code{x} is missing. Defaults to \code{"NA"}.} 27 | 28 | \item{pr_row_format}{(\code{list})\cr list of default formats coming from the general row.} 29 | 30 | \item{pr_row_na_str}{(\code{list})\cr list of default \code{"NA"} strings coming from the general row.} 31 | 32 | \item{round_type}{(\code{"iec"} or \code{"sas"})\cr the type of rounding to perform. iec, 33 | the default, peforms rounding compliant with IEC 60559 (see details), while 34 | sas performs nearest-value rounding consistent with rounding within SAS.} 35 | 36 | \item{shell}{(\code{flag})\cr whether the formats themselves should be returned instead of the 37 | values with formats applied. Defaults to \code{FALSE}.} 38 | } 39 | \value{ 40 | Formatted text. 41 | } 42 | \description{ 43 | This is a wrapper for \code{\link[formatters:format_value]{formatters::format_value()}} for use with \code{CellValue} objects 44 | } 45 | \examples{ 46 | cll <- CellValue(pi, format = "xx.xxx") 47 | format_rcell(cll) 48 | 49 | # Cell values precedes the row values 50 | cll <- CellValue(pi, format = "xx.xxx") 51 | format_rcell(cll, pr_row_format = "xx.x") 52 | 53 | # Similarly for NA values 54 | cll <- CellValue(NA, format = "xx.xxx", format_na_str = "This is THE NA") 55 | format_rcell(cll, pr_row_na_str = "This is NA") 56 | 57 | } 58 | -------------------------------------------------------------------------------- /man/gfc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_toString.R 3 | \name{get_formatted_cells} 4 | \alias{get_formatted_cells} 5 | \alias{get_formatted_cells,TableTree-method} 6 | \alias{get_formatted_cells,ElementaryTable-method} 7 | \alias{get_formatted_cells,TableRow-method} 8 | \alias{get_formatted_cells,LabelRow-method} 9 | \alias{get_cell_aligns} 10 | \alias{get_cell_aligns,TableTree-method} 11 | \alias{get_cell_aligns,ElementaryTable-method} 12 | \alias{get_cell_aligns,TableRow-method} 13 | \alias{get_cell_aligns,LabelRow-method} 14 | \title{Get formatted cells} 15 | \usage{ 16 | get_formatted_cells(obj, shell = FALSE, round_type = c("iec", "sas")) 17 | 18 | \S4method{get_formatted_cells}{TableTree}(obj, shell = FALSE, round_type = c("iec", "sas")) 19 | 20 | \S4method{get_formatted_cells}{ElementaryTable}(obj, shell = FALSE, round_type = c("iec", "sas")) 21 | 22 | \S4method{get_formatted_cells}{TableRow}(obj, shell = FALSE, round_type = c("iec", "sas")) 23 | 24 | \S4method{get_formatted_cells}{LabelRow}(obj, shell = FALSE, round_type = c("iec", "sas")) 25 | 26 | get_cell_aligns(obj) 27 | 28 | \S4method{get_cell_aligns}{TableTree}(obj) 29 | 30 | \S4method{get_cell_aligns}{ElementaryTable}(obj) 31 | 32 | \S4method{get_cell_aligns}{TableRow}(obj) 33 | 34 | \S4method{get_cell_aligns}{LabelRow}(obj) 35 | } 36 | \arguments{ 37 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 38 | 39 | \item{shell}{(\code{flag})\cr whether the formats themselves should be returned instead of the values with formats 40 | applied. Defaults to \code{FALSE}.} 41 | 42 | \item{round_type}{(\code{"iec"} or \code{"sas"})\cr the type of rounding to perform. iec, 43 | the default, peforms rounding compliant with IEC 60559 (see details), while 44 | sas performs nearest-value rounding consistent with rounding within SAS.} 45 | } 46 | \value{ 47 | The formatted print-strings for all (body) cells in \code{obj}. 48 | } 49 | \description{ 50 | Get formatted cells 51 | } 52 | \examples{ 53 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 54 | library(dplyr) 55 | 56 | iris2 <- iris \%>\% 57 | group_by(Species) \%>\% 58 | mutate(group = as.factor(rep_len(c("a", "b"), length.out = n()))) \%>\% 59 | ungroup() 60 | 61 | tbl <- basic_table() \%>\% 62 | split_cols_by("Species") \%>\% 63 | split_cols_by("group") \%>\% 64 | analyze(c("Sepal.Length", "Petal.Width"), afun = list_wrap_x(summary), format = "xx.xx") \%>\% 65 | build_table(iris2) 66 | 67 | get_formatted_cells(tbl) 68 | \dontshow{\}) # examplesIf} 69 | } 70 | -------------------------------------------------------------------------------- /man/head_tail.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_pos_and_access.R 3 | \docType{methods} 4 | \name{head} 5 | \alias{head} 6 | \alias{head,VTableTree-method} 7 | \alias{tail} 8 | \alias{tail,VTableTree-method} 9 | \title{Head and tail methods} 10 | \usage{ 11 | head(x, ...) 12 | 13 | \S4method{head}{VTableTree}( 14 | x, 15 | n = 6, 16 | ..., 17 | keep_topleft = TRUE, 18 | keep_titles = TRUE, 19 | keep_footers = keep_titles, 20 | reindex_refs = FALSE 21 | ) 22 | 23 | tail(x, ...) 24 | 25 | \S4method{tail}{VTableTree}( 26 | x, 27 | n = 6, 28 | ..., 29 | keep_topleft = TRUE, 30 | keep_titles = TRUE, 31 | keep_footers = keep_titles, 32 | reindex_refs = FALSE 33 | ) 34 | } 35 | \arguments{ 36 | \item{x}{an object} 37 | 38 | \item{...}{arguments to be passed to or from other methods.} 39 | 40 | \item{n}{an integer vector of length up to \code{dim(x)} (or 1, 41 | for non-dimensioned objects). A \code{logical} is silently coerced to 42 | integer. Values specify the indices to be 43 | selected in the corresponding dimension (or along the length) of the 44 | object. A positive value of \code{n[i]} includes the first/last 45 | \code{n[i]} indices in that dimension, while a negative value 46 | excludes the last/first \code{abs(n[i])}, including all remaining 47 | indices. \code{NA} or non-specified values (when \code{length(n) < 48 | length(dim(x))}) select all indices in that dimension. Must 49 | contain at least one non-missing value.} 50 | 51 | \item{keep_topleft}{(\code{flag})\cr if \code{TRUE} (the default), top_left material for the table will be carried over to the 52 | subset.} 53 | 54 | \item{keep_titles}{(\code{flag})\cr if \code{TRUE} (the default), all title material for the table will be carried over to the 55 | subset.} 56 | 57 | \item{keep_footers}{(\code{flag})\cr if \code{TRUE}, all footer material for the table will be carried over to the subset. It 58 | defaults to \code{keep_titles}.} 59 | 60 | \item{reindex_refs}{(\code{flag})\cr defaults to \code{FALSE}. If \code{TRUE}, referential footnotes will be reindexed for the 61 | subset.} 62 | } 63 | \description{ 64 | Head and tail methods 65 | } 66 | -------------------------------------------------------------------------------- /man/horizontal_sep.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{horizontal_sep} 4 | \alias{horizontal_sep} 5 | \alias{horizontal_sep,VTableTree-method} 6 | \alias{horizontal_sep<-} 7 | \alias{horizontal_sep<-,VTableTree-method} 8 | \alias{horizontal_sep<-,TableRow-method} 9 | \title{Access or recursively set header-body separator for tables} 10 | \usage{ 11 | horizontal_sep(obj) 12 | 13 | \S4method{horizontal_sep}{VTableTree}(obj) 14 | 15 | horizontal_sep(obj) <- value 16 | 17 | \S4method{horizontal_sep}{VTableTree}(obj) <- value 18 | 19 | \S4method{horizontal_sep}{TableRow}(obj) <- value 20 | } 21 | \arguments{ 22 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 23 | 24 | \item{value}{(\code{string})\cr string to use as new header/body separator.} 25 | } 26 | \value{ 27 | \itemize{ 28 | \item \code{horizontal_sep} returns the string acting as the header separator. 29 | \item \verb{horizontal_sep<-} returns \code{obj}, with the new header separator applied recursively to it and all its 30 | subtables. 31 | } 32 | } 33 | \description{ 34 | Access or recursively set header-body separator for tables 35 | } 36 | -------------------------------------------------------------------------------- /man/in_rows.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_afun_utils.R 3 | \name{in_rows} 4 | \alias{in_rows} 5 | \title{Create multiple rows in analysis or summary functions} 6 | \usage{ 7 | in_rows( 8 | ..., 9 | .list = NULL, 10 | .names = NULL, 11 | .labels = NULL, 12 | .formats = NULL, 13 | .indent_mods = NULL, 14 | .cell_footnotes = list(NULL), 15 | .row_footnotes = list(NULL), 16 | .aligns = NULL, 17 | .format_na_strs = NULL, 18 | .stat_names = list(NULL) 19 | ) 20 | } 21 | \arguments{ 22 | \item{...}{single row defining expressions.} 23 | 24 | \item{.list}{(\code{list})\cr list cell content (usually \code{rcells}). The \code{.list} is concatenated to \code{...}.} 25 | 26 | \item{.names}{(\code{character} or \code{NULL})\cr names of the returned list/structure.} 27 | 28 | \item{.labels}{(\code{character} or \code{NULL})\cr labels for the defined rows.} 29 | 30 | \item{.formats}{(\code{character} or \code{NULL})\cr formats for the values.} 31 | 32 | \item{.indent_mods}{(\code{integer} or \code{NULL})\cr indent modifications for the defined rows.} 33 | 34 | \item{.cell_footnotes}{(\code{list})\cr referential footnote messages to be associated by name with \emph{cells}.} 35 | 36 | \item{.row_footnotes}{(\code{list})\cr referential footnotes messages to be associated by name with \emph{rows}.} 37 | 38 | \item{.aligns}{(\code{character} or \code{NULL})\cr alignments for the cells. Standard for \code{NULL} is \code{"center"}. 39 | See \code{\link[formatters:list_formats]{formatters::list_valid_aligns()}} for currently supported alignments.} 40 | 41 | \item{.format_na_strs}{(\code{character} or \code{NULL})\cr NA strings for the cells.} 42 | 43 | \item{.stat_names}{(\code{list})\cr names for the statistics in the cells. 44 | It can be a vector of values. If \code{list(NULL)}, statistic names are not specified and will 45 | appear as \code{NA}.} 46 | } 47 | \value{ 48 | A \code{RowsVerticalSection} object (or \code{NULL}). The details of this object should be considered an 49 | internal implementation detail. 50 | } 51 | \description{ 52 | Define the cells that get placed into multiple rows in \code{afun}. 53 | } 54 | \note{ 55 | In post-processing, referential footnotes can also be added using row and column 56 | paths with \code{\link{fnotes_at_path<-}}. 57 | } 58 | \examples{ 59 | in_rows(1, 2, 3, .names = c("a", "b", "c")) 60 | in_rows(1, 2, 3, .labels = c("a", "b", "c")) 61 | in_rows(1, 2, 3, .names = c("a", "b", "c"), .labels = c("AAA", "BBB", "CCC")) 62 | in_rows( 63 | .list = list(a = c(NA, NA)), 64 | .formats = "xx - xx", 65 | .format_na_strs = list(c("asda", "lkjklj")) 66 | ) 67 | in_rows(.list = list(a = c(NA, NA)), .format_na_strs = c("asda", "lkjklj")) 68 | 69 | in_rows(.list = list(a = 1, b = 2, c = 3)) 70 | in_rows(1, 2, .list = list(3), .names = c("a", "b", "c")) 71 | 72 | lyt <- basic_table() \%>\% 73 | split_cols_by("ARM") \%>\% 74 | analyze("AGE", afun = function(x) { 75 | in_rows( 76 | "Mean (sd)" = rcell(c(mean(x), sd(x)), format = "xx.xx (xx.xx)"), 77 | "Range" = rcell(range(x), format = "xx.xx - xx.xx") 78 | ) 79 | }) 80 | 81 | tbl <- build_table(lyt, ex_adsl) 82 | tbl 83 | 84 | } 85 | \seealso{ 86 | \code{\link[=analyze]{analyze()}} 87 | } 88 | -------------------------------------------------------------------------------- /man/indent.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/indent.R 3 | \name{indent} 4 | \alias{indent} 5 | \title{Change indentation of all \code{rrows} in an \code{rtable}} 6 | \usage{ 7 | indent(x, by = 1) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{VTableTree})\cr an \code{rtable} object.} 11 | 12 | \item{by}{(\code{integer})\cr number to increase indentation of rows by. Can be negative. If final indentation is 13 | less than 0, the indentation is set to 0.} 14 | } 15 | \value{ 16 | \code{x} with its indent modifier incremented by \code{by}. 17 | } 18 | \description{ 19 | Change indentation of all \code{rrows} in an \code{rtable} 20 | } 21 | \examples{ 22 | is_setosa <- iris$Species == "setosa" 23 | m_tbl <- rtable( 24 | header = rheader( 25 | rrow(row.name = NULL, rcell("Sepal.Length", colspan = 2), rcell("Petal.Length", colspan = 2)), 26 | rrow(NULL, "mean", "median", "mean", "median") 27 | ), 28 | rrow( 29 | row.name = "All Species", 30 | mean(iris$Sepal.Length), median(iris$Sepal.Length), 31 | mean(iris$Petal.Length), median(iris$Petal.Length), 32 | format = "xx.xx" 33 | ), 34 | rrow( 35 | row.name = "Setosa", 36 | mean(iris$Sepal.Length[is_setosa]), median(iris$Sepal.Length[is_setosa]), 37 | mean(iris$Petal.Length[is_setosa]), median(iris$Petal.Length[is_setosa]), 38 | format = "xx.xx" 39 | ) 40 | ) 41 | indent(m_tbl) 42 | indent(m_tbl, 2) 43 | 44 | } 45 | -------------------------------------------------------------------------------- /man/indent_string.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_toString.R 3 | \name{indent_string} 4 | \alias{indent_string} 5 | \title{Indent strings} 6 | \usage{ 7 | indent_string(x, indent = 0, incr = 2, including_newline = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{character})\cr a character vector.} 11 | 12 | \item{indent}{(\code{numeric})\cr a vector of non-negative integers of length \code{length(x)}.} 13 | 14 | \item{incr}{(\code{integer(1)})\cr a non-negative number of spaces per indent level.} 15 | 16 | \item{including_newline}{(\code{flag})\cr whether newlines should also be indented.} 17 | } 18 | \value{ 19 | \code{x}, indented with left-padding with \code{indent * incr} white-spaces. 20 | } 21 | \description{ 22 | Used in rtables to indent row names for the ASCII output. 23 | } 24 | \examples{ 25 | indent_string("a", 0) 26 | indent_string("a", 1) 27 | indent_string(letters[1:3], 0:2) 28 | indent_string(paste0(letters[1:3], "\n", LETTERS[1:3]), 0:2) 29 | 30 | } 31 | -------------------------------------------------------------------------------- /man/insert_row_at_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_pos_and_access.R 3 | \name{insert_row_at_path} 4 | \alias{insert_row_at_path} 5 | \alias{insert_row_at_path,VTableTree,DataRow-method} 6 | \alias{insert_row_at_path,VTableTree,ANY-method} 7 | \title{Insert row at path} 8 | \usage{ 9 | insert_row_at_path(tt, path, value, after = FALSE) 10 | 11 | \S4method{insert_row_at_path}{VTableTree,DataRow}(tt, path, value, after = FALSE) 12 | 13 | \S4method{insert_row_at_path}{VTableTree,ANY}(tt, path, value) 14 | } 15 | \arguments{ 16 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 17 | 18 | \item{path}{(\code{character})\cr a vector path for a position within the structure of a \code{TableTree}. Each element 19 | represents a subsequent choice amongst the children of the previous choice.} 20 | 21 | \item{value}{(\code{ANY})\cr the new value.} 22 | 23 | \item{after}{(\code{flag})\cr whether \code{value} should be added as a row directly before (\code{FALSE}, the default) or after 24 | (\code{TRUE}) the row specified by \code{path}.} 25 | } 26 | \description{ 27 | Insert a row into an existing table directly before or directly after an existing data (i.e., non-content and 28 | non-label) row, specified by its path. 29 | } 30 | \examples{ 31 | lyt <- basic_table() \%>\% 32 | split_rows_by("COUNTRY", split_fun = keep_split_levels(c("CHN", "USA"))) \%>\% 33 | analyze("AGE") 34 | 35 | tbl <- build_table(lyt, DM) 36 | 37 | tbl2 <- insert_row_at_path( 38 | tbl, c("COUNTRY", "CHN", "AGE", "Mean"), 39 | rrow("new row", 555) 40 | ) 41 | tbl2 42 | 43 | tbl3 <- insert_row_at_path(tbl2, c("COUNTRY", "CHN", "AGE", "Mean"), 44 | rrow("new row redux", 888), 45 | after = TRUE 46 | ) 47 | tbl3 48 | 49 | } 50 | \seealso{ 51 | \code{\link[=DataRow]{DataRow()}}, \code{\link[=rrow]{rrow()}} 52 | } 53 | -------------------------------------------------------------------------------- /man/insert_rrow.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compatibility.R 3 | \name{insert_rrow} 4 | \alias{insert_rrow} 5 | \title{Insert \code{rrow}s at (before) a specific location} 6 | \usage{ 7 | insert_rrow(tbl, rrow, at = 1, ascontent = FALSE) 8 | } 9 | \arguments{ 10 | \item{tbl}{(\code{VTableTree})\cr a \code{rtable} object.} 11 | 12 | \item{rrow}{(\code{TableRow})\cr an \code{rrow} to append to \code{tbl}.} 13 | 14 | \item{at}{(\code{integer(1)})\cr position into which to put the \code{rrow}, defaults to beginning (i.e. row 1).} 15 | 16 | \item{ascontent}{(\code{flag})\cr currently ignored.} 17 | } 18 | \value{ 19 | A \code{TableTree} of the same specific class as \code{tbl}. 20 | } 21 | \description{ 22 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} 23 | } 24 | \details{ 25 | This function is deprecated and will be removed in a future release of \code{rtables}. Please use 26 | \code{\link[=insert_row_at_path]{insert_row_at_path()}} or \code{\link[=label_at_path]{label_at_path()}} instead. 27 | } 28 | \note{ 29 | Label rows (i.e. a row with no data values, only a \code{row.name}) can only be inserted at positions which do 30 | not already contain a label row when there is a non-trivial nested row structure in \code{tbl}. 31 | } 32 | \examples{ 33 | o <- options(warn = 0) 34 | lyt <- basic_table() \%>\% 35 | split_cols_by("Species") \%>\% 36 | analyze("Sepal.Length") 37 | 38 | tbl <- build_table(lyt, iris) 39 | 40 | insert_rrow(tbl, rrow("Hello World")) 41 | insert_rrow(tbl, rrow("Hello World"), at = 2) 42 | 43 | lyt2 <- basic_table() \%>\% 44 | split_cols_by("Species") \%>\% 45 | split_rows_by("Species") \%>\% 46 | analyze("Sepal.Length") 47 | 48 | tbl2 <- build_table(lyt2, iris) 49 | 50 | insert_rrow(tbl2, rrow("Hello World")) 51 | insert_rrow(tbl2, rrow("Hello World"), at = 2) 52 | insert_rrow(tbl2, rrow("Hello World"), at = 4) 53 | 54 | insert_rrow(tbl2, rrow("new row", 5, 6, 7)) 55 | 56 | insert_rrow(tbl2, rrow("new row", 5, 6, 7), at = 3) 57 | 58 | options(o) 59 | 60 | } 61 | -------------------------------------------------------------------------------- /man/is_rtable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{is_rtable} 4 | \alias{is_rtable} 5 | \title{Check if an object is a valid \code{rtable}} 6 | \usage{ 7 | is_rtable(x) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{ANY})\cr an object.} 11 | } 12 | \value{ 13 | \code{TRUE} if \code{x} is a formal \code{TableTree} object, \code{FALSE} otherwise. 14 | } 15 | \description{ 16 | Check if an object is a valid \code{rtable} 17 | } 18 | \examples{ 19 | is_rtable(build_table(basic_table(), iris)) 20 | 21 | } 22 | -------------------------------------------------------------------------------- /man/label_at_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_pos_and_access.R 3 | \name{label_at_path} 4 | \alias{label_at_path} 5 | \alias{label_at_path<-} 6 | \title{Label at path} 7 | \usage{ 8 | label_at_path(tt, path) 9 | 10 | label_at_path(tt, path) <- value 11 | } 12 | \arguments{ 13 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 14 | 15 | \item{path}{(\code{character})\cr a vector path for a position within the structure of a \code{TableTree}. Each element 16 | represents a subsequent choice amongst the children of the previous choice.} 17 | 18 | \item{value}{(\code{ANY})\cr the new value.} 19 | } 20 | \description{ 21 | Accesses or sets the label at a path. 22 | } 23 | \details{ 24 | If \code{path} resolves to a single row, the label for that row is retrieved or set. If, instead, \code{path} resolves to a 25 | subtable, the text for the row-label associated with that path is retrieved or set. In the subtable case, if the 26 | label text is set to a non-\code{NA} value, the \code{labelrow} will be set to visible, even if it was not before. Similarly, 27 | if the label row text for a subtable is set to \code{NA}, the label row will bet set to non-visible, so the row will not 28 | appear at all when the table is printed. 29 | } 30 | \note{ 31 | When changing the row labels for content rows, it is important to path all the way to the \emph{row}. Paths 32 | ending in \code{"@content"} will not exhibit the behavior you want, and are thus an error. See \code{\link[=row_paths]{row_paths()}} for help 33 | determining the full paths to content rows. 34 | } 35 | \examples{ 36 | lyt <- basic_table() \%>\% 37 | split_rows_by("COUNTRY", split_fun = keep_split_levels(c("CHN", "USA"))) \%>\% 38 | analyze("AGE") 39 | 40 | tbl <- build_table(lyt, DM) 41 | 42 | label_at_path(tbl, c("COUNTRY", "CHN")) 43 | 44 | label_at_path(tbl, c("COUNTRY", "USA")) <- "United States" 45 | tbl 46 | 47 | } 48 | -------------------------------------------------------------------------------- /man/length-CellValue-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/00tabletrees.R 3 | \name{length,CellValue-method} 4 | \alias{length,CellValue-method} 5 | \title{Length of a Cell value} 6 | \usage{ 7 | \S4method{length}{CellValue}(x) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{CellValue})\cr a \code{CellValue} object.} 11 | } 12 | \value{ 13 | Always returns \code{1L}. 14 | } 15 | \description{ 16 | Length of a Cell value 17 | } 18 | -------------------------------------------------------------------------------- /man/list_wrap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{list_wrap_x} 4 | \alias{list_wrap_x} 5 | \alias{list_wrap_df} 6 | \title{Returns a function that coerces the return values of a function to a list} 7 | \usage{ 8 | list_wrap_x(f) 9 | 10 | list_wrap_df(f) 11 | } 12 | \arguments{ 13 | \item{f}{(\code{function})\cr the function to wrap.} 14 | } 15 | \value{ 16 | A function that returns a list of \code{CellValue} objects. 17 | } 18 | \description{ 19 | Returns a function that coerces the return values of a function to a list 20 | } 21 | \details{ 22 | \code{list_wrap_x} generates a wrapper which takes \code{x} as its first argument, while \code{list_wrap_df} generates an 23 | otherwise identical wrapper function whose first argument is named \code{df}. 24 | 25 | We provide both because when using the functions as tabulation in \code{\link[=analyze]{analyze()}}, functions which take \code{df} as 26 | their first argument are passed the full subset data frame, while those which accept anything else notably 27 | including \code{x} are passed only the relevant subset of the variable being analyzed. 28 | } 29 | \examples{ 30 | summary(iris$Sepal.Length) 31 | 32 | f <- list_wrap_x(summary) 33 | f(x = iris$Sepal.Length) 34 | 35 | f2 <- list_wrap_df(summary) 36 | f2(df = iris$Sepal.Length) 37 | 38 | } 39 | \author{ 40 | Gabriel Becker 41 | } 42 | -------------------------------------------------------------------------------- /man/make_col_df.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_paginate.R 3 | \name{make_col_df} 4 | \alias{make_col_df} 5 | \title{Column layout summary} 6 | \usage{ 7 | make_col_df( 8 | tt, 9 | colwidths = NULL, 10 | visible_only = TRUE, 11 | na_str = "", 12 | ccount_format = colcount_format(tt) \%||\% "(N=xx)" 13 | ) 14 | } 15 | \arguments{ 16 | \item{tt}{(\code{ANY})\cr object representing the table-like object to be summarized.} 17 | 18 | \item{colwidths}{(\code{numeric})\cr internal detail, do not set manually.} 19 | 20 | \item{visible_only}{(\code{flag})\cr should only visible aspects of the table structure be reflected 21 | in this summary. Defaults to \code{TRUE}. May not be supported by all methods.} 22 | 23 | \item{na_str}{(\code{character(1)})\cr The string to display when a column count is NA. Users should not need to set this.} 24 | 25 | \item{ccount_format}{(\code{FormatSpec})\cr The format to be used by default for 26 | column counts if one is not specified for an individual column count.} 27 | } 28 | \description{ 29 | Used for pagination. Generate a structural summary of the columns of an \code{rtables} table and return it as a 30 | \code{data.frame}. 31 | } 32 | -------------------------------------------------------------------------------- /man/make_col_row_df.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.R 3 | \name{row_paths} 4 | \alias{row_paths} 5 | \alias{col_paths} 6 | \title{Get a list of table row/column paths} 7 | \usage{ 8 | row_paths(x) 9 | 10 | col_paths(x) 11 | } 12 | \arguments{ 13 | \item{x}{(\code{VTableTree})\cr an \code{rtable} object.} 14 | } 15 | \value{ 16 | A list of paths to each row/column within \code{x}. 17 | } 18 | \description{ 19 | Get a list of table row/column paths 20 | } 21 | \examples{ 22 | lyt <- basic_table() \%>\% 23 | split_cols_by("ARM") \%>\% 24 | analyze(c("SEX", "AGE")) 25 | 26 | tbl <- build_table(lyt, ex_adsl) 27 | tbl 28 | 29 | row_paths(tbl) 30 | col_paths(tbl) 31 | 32 | cell_values(tbl, c("AGE", "Mean"), c("ARM", "B: Placebo")) 33 | 34 | } 35 | \seealso{ 36 | \code{\link[=cell_values]{cell_values()}}, \code{\link{fnotes_at_path<-}}, \code{\link[=row_paths_summary]{row_paths_summary()}}, \code{\link[=col_paths_summary]{col_paths_summary()}} 37 | } 38 | -------------------------------------------------------------------------------- /man/make_split_result.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/make_split_fun.R 3 | \name{make_split_result} 4 | \alias{make_split_result} 5 | \alias{add_to_split_result} 6 | \title{Construct split result object} 7 | \usage{ 8 | make_split_result( 9 | values, 10 | datasplit, 11 | labels, 12 | extras = NULL, 13 | subset_exprs = vector("list", length(values)) 14 | ) 15 | 16 | add_to_split_result( 17 | splres, 18 | values, 19 | datasplit, 20 | labels, 21 | extras = NULL, 22 | subset_exprs = NULL 23 | ) 24 | } 25 | \arguments{ 26 | \item{values}{(\code{character} or \code{list(SplitValue)})\cr the values associated with each facet.} 27 | 28 | \item{datasplit}{(\code{list(data.frame)})\cr the facet data for each facet generated in the split.} 29 | 30 | \item{labels}{(\code{character})\cr the labels associated with each facet.} 31 | 32 | \item{extras}{(\code{list} or \code{NULL})\cr extra values associated with each of the facets which will be passed to 33 | analysis functions applied within the facet.} 34 | 35 | \item{subset_exprs}{(\code{list})\cr A list of subsetting expressions (e.g., 36 | created with \code{quote()}) to be used during column subsetting.} 37 | 38 | \item{splres}{(\code{list})\cr a list representing the result of splitting.} 39 | } 40 | \value{ 41 | A named list representing the facets generated by the split with elements \code{values}, \code{datasplit}, and 42 | \code{labels}, which are the same length and correspond to each other element-wise. 43 | } 44 | \description{ 45 | These functions can be used to create or add to a split result in functions which implement core splitting or 46 | post-processing within a custom split function. 47 | } 48 | \details{ 49 | These functions performs various housekeeping tasks to ensure that the split result list is as the rtables 50 | internals expect it, most of which are not relevant to end users. 51 | } 52 | \examples{ 53 | splres <- make_split_result( 54 | values = c("hi", "lo"), 55 | datasplit = list(hi = mtcars, lo = mtcars[1:10, ]), 56 | labels = c("more data", "less data"), 57 | subset_exprs = list(expression(TRUE), expression(seq_along(wt) <= 10)) 58 | ) 59 | 60 | splres2 <- add_to_split_result(splres, 61 | values = "med", 62 | datasplit = list(med = mtcars[1:20, ]), 63 | labels = "kinda some data", 64 | subset_exprs = quote(seq_along(wt) <= 20) 65 | ) 66 | 67 | } 68 | \seealso{ 69 | Other make_custom_split: 70 | \code{\link{add_combo_facet}()}, 71 | \code{\link{drop_facet_levels}()}, 72 | \code{\link{make_split_fun}()}, 73 | \code{\link{trim_levels_in_facets}()} 74 | 75 | Other make_custom_split: 76 | \code{\link{add_combo_facet}()}, 77 | \code{\link{drop_facet_levels}()}, 78 | \code{\link{make_split_fun}()}, 79 | \code{\link{trim_levels_in_facets}()} 80 | } 81 | \concept{make_custom_split} 82 | -------------------------------------------------------------------------------- /man/manual_cols.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{manual_cols} 4 | \alias{manual_cols} 5 | \title{Manual column declaration} 6 | \usage{ 7 | manual_cols(..., .lst = list(...), ccount_format = NULL) 8 | } 9 | \arguments{ 10 | \item{...}{one or more vectors of levels to appear in the column space. If more than one set of levels is given, 11 | the values of the second are nested within each value of the first, and so on.} 12 | 13 | \item{.lst}{(\code{list})\cr a list of sets of levels, by default populated via \code{list(...)}.} 14 | 15 | \item{ccount_format}{(\code{FormatSpec})\cr the format to use when counts are displayed.} 16 | } 17 | \value{ 18 | An \code{InstantiatedColumnInfo} object, suitable for declaring the column structure for a manually constructed 19 | table. 20 | } 21 | \description{ 22 | Manual column declaration 23 | } 24 | \examples{ 25 | # simple one level column space 26 | rows <- lapply(1:5, function(i) { 27 | DataRow(rep(i, times = 3)) 28 | }) 29 | tbl <- TableTree(kids = rows, cinfo = manual_cols(split = c("a", "b", "c"))) 30 | tbl 31 | 32 | # manually declared nesting 33 | tbl2 <- TableTree( 34 | kids = list(DataRow(as.list(1:4))), 35 | cinfo = manual_cols( 36 | Arm = c("Arm A", "Arm B"), 37 | Gender = c("M", "F") 38 | ) 39 | ) 40 | tbl2 41 | 42 | } 43 | \author{ 44 | Gabriel Becker 45 | } 46 | -------------------------------------------------------------------------------- /man/matrix_form-VTableTree-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_toString.R 3 | \name{matrix_form,VTableTree-method} 4 | \alias{matrix_form,VTableTree-method} 5 | \title{Transform an \code{rtable} to a list of matrices which can be used for outputting} 6 | \usage{ 7 | \S4method{matrix_form}{VTableTree}( 8 | obj, 9 | indent_rownames = FALSE, 10 | expand_newlines = TRUE, 11 | indent_size = 2, 12 | fontspec = NULL, 13 | col_gap = 3L, 14 | round_type = c("iec", "sas") 15 | ) 16 | } 17 | \arguments{ 18 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 19 | 20 | \item{indent_rownames}{(\code{flag})\cr if \code{TRUE}, the column with the row names in the \code{strings} matrix of the output 21 | has indented row names (strings pre-fixed).} 22 | 23 | \item{expand_newlines}{(\code{flag})\cr whether the matrix form generated should expand rows whose values contain 24 | newlines into multiple 'physical' rows (as they will appear when rendered into ASCII). Defaults to \code{TRUE}.} 25 | 26 | \item{indent_size}{(\code{numeric(1)})\cr number of spaces to use per indent level. Defaults to 2.} 27 | 28 | \item{fontspec}{(\code{font_spec})\cr The font that should be used by default when 29 | rendering this \code{MatrixPrintForm} object, or NULL (the default).} 30 | 31 | \item{col_gap}{(\code{numeric(1)})]\cr The number of spaces (in the font specified 32 | by \code{fontspec}) that should be placed between columns when the table 33 | is rendered directly to text (e.g., by \code{toString} or \code{export_as_txt}). Defaults 34 | to \code{3}.} 35 | 36 | \item{round_type}{(\code{"iec"} or \code{"sas"})\cr the type of rounding to perform. iec, 37 | the default, peforms rounding compliant with IEC 60559 (see details), while 38 | sas performs nearest-value rounding consistent with rounding within SAS.} 39 | } 40 | \value{ 41 | A list with the following elements: 42 | \describe{ 43 | \item{\code{strings}}{The content, as it should be printed, of the top-left material, column headers, row labels, 44 | and cell values of \code{tt}.} 45 | \item{\code{spans}}{The column-span information for each print-string in the \code{strings} matrix.} 46 | \item{\code{aligns}}{The text alignment for each print-string in the \code{strings} matrix.} 47 | \item{\code{display}}{Whether each print-string in the strings matrix should be printed.} 48 | \item{\code{row_info}}{The \code{data.frame} generated by \code{make_row_df}.} 49 | } 50 | 51 | With an additional \code{nrow_header} attribute indicating the number of pseudo "rows" that the column structure defines. 52 | } 53 | \description{ 54 | Although \code{rtables} are represented as a tree data structure when outputting the table to ASCII or HTML 55 | it is useful to map the \code{rtable} to an in-between state with the formatted cells in a matrix form. 56 | } 57 | \details{ 58 | The strings in the return object are defined as follows: row labels are those determined by \code{make_row_df} and cell 59 | values are determined using \code{get_formatted_cells}. (Column labels are calculated using a non-exported internal 60 | function. 61 | } 62 | \examples{ 63 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 64 | library(dplyr) 65 | 66 | iris2 <- iris \%>\% 67 | group_by(Species) \%>\% 68 | mutate(group = as.factor(rep_len(c("a", "b"), length.out = n()))) \%>\% 69 | ungroup() 70 | 71 | lyt <- basic_table() \%>\% 72 | split_cols_by("Species") \%>\% 73 | split_cols_by("group") \%>\% 74 | analyze(c("Sepal.Length", "Petal.Width"), 75 | afun = list_wrap_x(summary), format = "xx.xx" 76 | ) 77 | 78 | lyt 79 | 80 | tbl <- build_table(lyt, iris2) 81 | 82 | matrix_form(tbl) 83 | \dontshow{\}) # examplesIf} 84 | } 85 | -------------------------------------------------------------------------------- /man/names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{names,VTableNodeInfo-method} 4 | \alias{names,VTableNodeInfo-method} 5 | \alias{names,InstantiatedColumnInfo-method} 6 | \alias{names,LayoutColTree-method} 7 | \alias{row.names,VTableTree-method} 8 | \title{Names of a \code{TableTree}} 9 | \usage{ 10 | \S4method{names}{VTableNodeInfo}(x) 11 | 12 | \S4method{names}{InstantiatedColumnInfo}(x) 13 | 14 | \S4method{names}{LayoutColTree}(x) 15 | 16 | \S4method{row.names}{VTableTree}(x) 17 | } 18 | \arguments{ 19 | \item{x}{(\code{TableTree})\cr the object.} 20 | } 21 | \value{ 22 | The column names of \code{x}, as defined in the details above. 23 | } 24 | \description{ 25 | Names of a \code{TableTree} 26 | } 27 | \details{ 28 | For \code{TableTree}s with more than one level of splitting in columns, the names are defined to be the top-level 29 | split values repped out across the columns that they span. 30 | } 31 | -------------------------------------------------------------------------------- /man/no_info.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{no_colinfo} 4 | \alias{no_colinfo} 5 | \alias{no_colinfo,VTableNodeInfo-method} 6 | \alias{no_colinfo,InstantiatedColumnInfo-method} 7 | \title{Exported for use in \code{tern}} 8 | \usage{ 9 | no_colinfo(obj) 10 | 11 | \S4method{no_colinfo}{VTableNodeInfo}(obj) 12 | 13 | \S4method{no_colinfo}{InstantiatedColumnInfo}(obj) 14 | } 15 | \arguments{ 16 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 17 | } 18 | \value{ 19 | \code{TRUE} if the object has no/empty instantiated column information, \code{FALSE} otherwise. 20 | } 21 | \description{ 22 | Does the \code{table}/\code{row}/\code{InstantiatedColumnInfo} object contain no column structure information? 23 | } 24 | -------------------------------------------------------------------------------- /man/prune_table.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compare_tables.R 3 | \name{prune_table} 4 | \alias{prune_table} 5 | \title{Recursively prune a \code{TableTree}} 6 | \usage{ 7 | prune_table( 8 | tt, 9 | prune_func = prune_empty_level, 10 | stop_depth = NA_real_, 11 | depth = 0, 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 17 | 18 | \item{prune_func}{(\code{function})\cr a function to be called on each subtree which returns \code{TRUE} if the 19 | entire subtree should be removed.} 20 | 21 | \item{stop_depth}{(\code{numeric(1)})\cr the depth after which subtrees should not be checked for pruning. 22 | Defaults to \code{NA} which indicates pruning should happen at all levels.} 23 | 24 | \item{depth}{(\code{numeric(1)})\cr used internally, not intended to be set by the end user.} 25 | 26 | \item{...}{named arguments to optionally be passed down to \code{prune_func} if it 27 | accepts them (or \code{...})} 28 | } 29 | \value{ 30 | A \code{TableTree} pruned via recursive application of \code{prune_func}. 31 | } 32 | \description{ 33 | Recursively prune a \code{TableTree} 34 | } 35 | \examples{ 36 | adsl <- ex_adsl 37 | levels(adsl$SEX) <- c(levels(ex_adsl$SEX), "OTHER") 38 | 39 | tbl_to_prune <- basic_table() \%>\% 40 | split_cols_by("ARM") \%>\% 41 | split_rows_by("SEX") \%>\% 42 | summarize_row_groups() \%>\% 43 | split_rows_by("STRATA1") \%>\% 44 | summarize_row_groups() \%>\% 45 | analyze("AGE") \%>\% 46 | build_table(adsl) 47 | 48 | tbl_to_prune \%>\% prune_table() 49 | 50 | } 51 | \seealso{ 52 | \code{\link[=prune_empty_level]{prune_empty_level()}} for details on this and several other basic pruning functions included 53 | in the \code{rtables} package. 54 | } 55 | -------------------------------------------------------------------------------- /man/rbind.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compatibility.R 3 | \name{rbindl_rtables} 4 | \alias{rbindl_rtables} 5 | \alias{rbind} 6 | \alias{rbind,VTableNodeInfo-method} 7 | \alias{rbind2,VTableNodeInfo,ANY-method} 8 | \title{Row-bind \code{TableTree} and related objects} 9 | \usage{ 10 | rbindl_rtables( 11 | x, 12 | gap = lifecycle::deprecated(), 13 | check_headers = lifecycle::deprecated() 14 | ) 15 | 16 | \S4method{rbind}{VTableNodeInfo}(..., deparse.level = 1) 17 | 18 | \S4method{rbind2}{VTableNodeInfo,ANY}(x, y) 19 | } 20 | \arguments{ 21 | \item{x}{(\code{VTableNodeInfo})\cr \code{TableTree}, \code{ElementaryTable}, or \code{TableRow} object.} 22 | 23 | \item{gap}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} ignored.} 24 | 25 | \item{check_headers}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} ignored.} 26 | 27 | \item{...}{(\code{ANY})\cr elements to be stacked.} 28 | 29 | \item{deparse.level}{(\code{numeric(1)})\cr currently ignored.} 30 | 31 | \item{y}{(\code{VTableNodeInfo})\cr \code{TableTree}, \code{ElementaryTable}, or \code{TableRow} object.} 32 | } 33 | \value{ 34 | A formal table object. 35 | } 36 | \description{ 37 | Row-bind \code{TableTree} and related objects 38 | } 39 | \note{ 40 | When objects are row-bound, titles and footer information is retained from the first object (if any exists) if all 41 | other objects have no titles/footers or have identical titles/footers. Otherwise, all titles/footers are removed 42 | and must be set for the bound table via the \code{\link[formatters:title_footer]{formatters::main_title()}}, \code{\link[formatters:title_footer]{formatters::subtitles()}}, 43 | \code{\link[formatters:title_footer]{formatters::main_footer()}}, and \code{\link[formatters:title_footer]{formatters::prov_footer()}} functions. 44 | } 45 | \examples{ 46 | mtbl <- rtable( 47 | header = rheader( 48 | rrow(row.name = NULL, rcell("Sepal.Length", colspan = 2), rcell("Petal.Length", colspan = 2)), 49 | rrow(NULL, "mean", "median", "mean", "median") 50 | ), 51 | rrow( 52 | row.name = "All Species", 53 | mean(iris$Sepal.Length), median(iris$Sepal.Length), 54 | mean(iris$Petal.Length), median(iris$Petal.Length), 55 | format = "xx.xx" 56 | ) 57 | ) 58 | 59 | mtbl2 <- with(subset(iris, Species == "setosa"), rtable( 60 | header = rheader( 61 | rrow(row.name = NULL, rcell("Sepal.Length", colspan = 2), rcell("Petal.Length", colspan = 2)), 62 | rrow(NULL, "mean", "median", "mean", "median") 63 | ), 64 | rrow( 65 | row.name = "Setosa", 66 | mean(Sepal.Length), median(Sepal.Length), 67 | mean(Petal.Length), median(Petal.Length), 68 | format = "xx.xx" 69 | ) 70 | )) 71 | 72 | rbind(mtbl, mtbl2) 73 | rbind(mtbl, rrow(), mtbl2) 74 | rbind(mtbl, rrow("aaa"), indent(mtbl2)) 75 | 76 | } 77 | -------------------------------------------------------------------------------- /man/rcell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_afun_utils.R 3 | \name{rcell} 4 | \alias{rcell} 5 | \alias{non_ref_rcell} 6 | \title{Cell value constructors} 7 | \usage{ 8 | rcell( 9 | x, 10 | format = NULL, 11 | colspan = 1L, 12 | label = NULL, 13 | indent_mod = NULL, 14 | footnotes = NULL, 15 | align = NULL, 16 | format_na_str = NULL, 17 | stat_names = NULL 18 | ) 19 | 20 | non_ref_rcell( 21 | x, 22 | is_ref, 23 | format = NULL, 24 | colspan = 1L, 25 | label = NULL, 26 | indent_mod = NULL, 27 | refval = NULL, 28 | align = "center", 29 | format_na_str = NULL 30 | ) 31 | } 32 | \arguments{ 33 | \item{x}{(\code{ANY})\cr cell value.} 34 | 35 | \item{format}{(\code{string} or \code{function})\cr the format label (string) or \code{formatters} function to apply to \code{x}. 36 | See \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for currently supported format labels.} 37 | 38 | \item{colspan}{(\code{integer(1)})\cr column span value.} 39 | 40 | \item{label}{(\code{string} or \code{NULL})\cr label. If non-\code{NULL}, it will be looked at when determining row labels.} 41 | 42 | \item{indent_mod}{(\code{numeric})\cr modifier for the default indent position for the structure created by this 43 | function (subtable, content table, or row) \emph{and all of that structure's children}. Defaults to 0, which 44 | corresponds to the unmodified default behavior.} 45 | 46 | \item{footnotes}{(\code{list} or \code{NULL})\cr referential footnote messages for the cell.} 47 | 48 | \item{align}{(\code{string} or \code{NULL})\cr alignment the value should be rendered with. Defaults to \code{"center"} if 49 | \code{NULL} is used. See \code{\link[formatters:list_formats]{formatters::list_valid_aligns()}} for all currently supported alignments.} 50 | 51 | \item{format_na_str}{(\code{string})\cr string which should be displayed when formatted if this cell's value(s) 52 | are all \code{NA}.} 53 | 54 | \item{stat_names}{(\code{character} or \code{NA})\cr names for the statistics in the cell. It can be a vector of strings. 55 | If \code{NA}, statistic names are not specified.} 56 | 57 | \item{is_ref}{(\code{flag})\cr whether function is being used in the reference column (i.e. \code{.in_ref_col} should be 58 | passed to this argument).} 59 | 60 | \item{refval}{(\code{ANY})\cr value to use when in the reference column. Defaults to \code{NULL}.} 61 | } 62 | \value{ 63 | An object representing the value within a single cell within a populated table. The underlying structure 64 | of this object is an implementation detail and should not be relied upon beyond calling accessors for the class. 65 | } 66 | \description{ 67 | Construct a cell value and associate formatting, labeling, indenting, and column spanning information with it. 68 | } 69 | \details{ 70 | \code{non_ref_rcell} provides the common \emph{blank for cells in the reference column, this value otherwise}, and should 71 | be passed the value of \code{.in_ref_col} when it is used. 72 | } 73 | \note{ 74 | Currently column spanning is only supported for defining header structure. 75 | } 76 | \examples{ 77 | rcell(1, format = "xx.x") 78 | rcell(c(1, 2), format = c("xx - xx")) 79 | rcell(c(1, 2), stat_names = c("Rand1", "Rand2")) 80 | 81 | } 82 | -------------------------------------------------------------------------------- /man/reexports.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_export.R 3 | \docType{import} 4 | \name{reexports} 5 | \alias{reexports} 6 | \alias{export_as_txt} 7 | \alias{export_as_pdf} 8 | \title{Objects exported from other packages} 9 | \examples{ 10 | lyt <- basic_table() \%>\% 11 | split_cols_by("ARM") \%>\% 12 | analyze(c("AGE", "BMRKR2", "COUNTRY")) 13 | 14 | tbl <- build_table(lyt, ex_adsl) 15 | 16 | cat(export_as_txt(tbl, file = NULL, paginate = TRUE, lpp = 8)) 17 | 18 | \dontrun{ 19 | tf <- tempfile(fileext = ".txt") 20 | export_as_txt(tbl, file = tf) 21 | system2("cat", tf) 22 | } 23 | 24 | lyt <- basic_table() \%>\% 25 | split_cols_by("ARM") \%>\% 26 | analyze(c("AGE", "BMRKR2", "COUNTRY")) 27 | 28 | tbl <- build_table(lyt, ex_adsl) 29 | 30 | \dontrun{ 31 | tf <- tempfile(fileext = ".pdf") 32 | export_as_pdf(tbl, file = tf, pg_height = 4) 33 | tf <- tempfile(fileext = ".pdf") 34 | export_as_pdf(tbl, file = tf, lpp = 8) 35 | } 36 | 37 | } 38 | \keyword{internal} 39 | \description{ 40 | These objects are imported from other packages. Follow the links 41 | below to see their documentation. 42 | 43 | \describe{ 44 | \item{formatters}{\code{\link[formatters]{export_as_pdf}}, \code{\link[formatters]{export_as_txt}}} 45 | }} 46 | 47 | -------------------------------------------------------------------------------- /man/ref_fnotes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{row_footnotes} 4 | \alias{row_footnotes} 5 | \alias{row_footnotes<-} 6 | \alias{cell_footnotes} 7 | \alias{cell_footnotes<-} 8 | \alias{col_fnotes_here} 9 | \alias{col_fnotes_here,ANY-method} 10 | \alias{col_fnotes_here<-} 11 | \alias{col_footnotes} 12 | \alias{col_footnotes<-} 13 | \alias{ref_index} 14 | \alias{ref_index<-} 15 | \alias{ref_symbol} 16 | \alias{ref_symbol<-} 17 | \alias{ref_msg} 18 | \alias{fnotes_at_path<-} 19 | \title{Referential footnote accessors} 20 | \usage{ 21 | row_footnotes(obj) 22 | 23 | row_footnotes(obj) <- value 24 | 25 | cell_footnotes(obj) 26 | 27 | cell_footnotes(obj) <- value 28 | 29 | col_fnotes_here(obj) 30 | 31 | \S4method{col_fnotes_here}{ANY}(obj) 32 | 33 | col_fnotes_here(obj) <- value 34 | 35 | col_footnotes(obj) 36 | 37 | col_footnotes(obj) <- value 38 | 39 | ref_index(obj) 40 | 41 | ref_index(obj) <- value 42 | 43 | ref_symbol(obj) 44 | 45 | ref_symbol(obj) <- value 46 | 47 | ref_msg(obj) 48 | 49 | fnotes_at_path(obj, rowpath = NULL, colpath = NULL, reset_idx = TRUE) <- value 50 | } 51 | \arguments{ 52 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 53 | 54 | \item{value}{(\code{ANY})\cr the new value.} 55 | 56 | \item{rowpath}{(\code{character} or \code{NULL})\cr path within row structure. \code{NULL} indicates the footnote should 57 | go on the column rather than cell.} 58 | 59 | \item{colpath}{(\code{character} or \code{NULL})\cr path within column structure. \code{NULL} indicates footnote should go 60 | on the row rather than cell.} 61 | 62 | \item{reset_idx}{(\code{flag})\cr whether the numbering for referential footnotes should be immediately 63 | recalculated. Defaults to \code{TRUE}.} 64 | } 65 | \description{ 66 | Access and set the referential footnotes aspects of a built table. 67 | } 68 | \examples{ 69 | # How to add referencial footnotes after having created a table 70 | lyt <- basic_table() \%>\% 71 | split_rows_by("SEX", page_by = TRUE) \%>\% 72 | analyze("AGE") 73 | 74 | tbl <- build_table(lyt, DM) 75 | tbl <- trim_rows(tbl) 76 | # Check the row and col structure to add precise references 77 | # row_paths(tbl) 78 | # col_paths(t) 79 | # row_paths_summary(tbl) 80 | # col_paths_summary(tbl) 81 | 82 | # Add the citation numbers on the table and relative references in the footnotes 83 | fnotes_at_path(tbl, rowpath = c("SEX", "F", "AGE", "Mean")) <- "Famous paper 1" 84 | fnotes_at_path(tbl, rowpath = c("SEX", "UNDIFFERENTIATED")) <- "Unfamous paper 2" 85 | # tbl 86 | 87 | } 88 | \seealso{ 89 | \code{\link[=row_paths]{row_paths()}}, \code{\link[=col_paths]{col_paths()}}, \code{\link[=row_paths_summary]{row_paths_summary()}}, \code{\link[=col_paths_summary]{col_paths_summary()}} 90 | } 91 | -------------------------------------------------------------------------------- /man/rheader.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compatibility.R 3 | \name{rheader} 4 | \alias{rheader} 5 | \title{Create a header} 6 | \usage{ 7 | rheader(..., format = "xx", .lst = NULL) 8 | } 9 | \arguments{ 10 | \item{...}{row specifications, either as character vectors or the output from \code{\link[=rrow]{rrow()}}, \code{\link[=DataRow]{DataRow()}}, 11 | \code{\link[=LabelRow]{LabelRow()}}, etc.} 12 | 13 | \item{format}{(\code{string}, \code{function}, or \code{list})\cr the format label (string) or formatter function to apply to the 14 | cell values passed via \code{...}. See \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for currently supported format labels.} 15 | 16 | \item{.lst}{(\code{list})\cr an already-collected list of arguments to be used instead of the elements of \code{...}. 17 | Arguments passed via \code{...} will be ignored if this is specified.} 18 | } 19 | \value{ 20 | A \code{InstantiatedColumnInfo} object. 21 | } 22 | \description{ 23 | Create a header 24 | } 25 | \examples{ 26 | h1 <- rheader(c("A", "B", "C")) 27 | h1 28 | 29 | h2 <- rheader( 30 | rrow(NULL, rcell("group 1", colspan = 2), rcell("group 2", colspan = 2)), 31 | rrow(NULL, "A", "B", "A", "B") 32 | ) 33 | h2 34 | 35 | } 36 | \seealso{ 37 | Other compatibility: 38 | \code{\link{rrow}()}, 39 | \code{\link{rrowl}()}, 40 | \code{\link{rtable}()} 41 | } 42 | \concept{compatibility} 43 | -------------------------------------------------------------------------------- /man/rm_all_colcounts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{rm_all_colcounts} 4 | \alias{rm_all_colcounts} 5 | \alias{rm_all_colcounts,VTableTree-method} 6 | \alias{rm_all_colcounts,InstantiatedColumnInfo-method} 7 | \alias{rm_all_colcounts,LayoutColTree-method} 8 | \alias{rm_all_colcounts,LayoutColLeaf-method} 9 | \title{Set all column counts at all levels of nesting to NA} 10 | \usage{ 11 | rm_all_colcounts(obj) 12 | 13 | \S4method{rm_all_colcounts}{VTableTree}(obj) 14 | 15 | \S4method{rm_all_colcounts}{InstantiatedColumnInfo}(obj) 16 | 17 | \S4method{rm_all_colcounts}{LayoutColTree}(obj) 18 | 19 | \S4method{rm_all_colcounts}{LayoutColLeaf}(obj) 20 | } 21 | \arguments{ 22 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 23 | } 24 | \value{ 25 | \code{obj} with all column counts reset to missing 26 | } 27 | \description{ 28 | Set all column counts at all levels of nesting to NA 29 | } 30 | \examples{ 31 | lyt <- basic_table() \%>\% 32 | split_cols_by("ARM") \%>\% 33 | split_cols_by("SEX") \%>\% 34 | analyze("AGE") 35 | tbl <- build_table(lyt, ex_adsl) 36 | 37 | # before 38 | col_counts(tbl) 39 | tbl <- rm_all_colcounts(tbl) 40 | col_counts(tbl) 41 | } 42 | -------------------------------------------------------------------------------- /man/row_accessors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{obj_avar} 4 | \alias{obj_avar} 5 | \alias{obj_avar,TableRow-method} 6 | \alias{obj_avar,ElementaryTable-method} 7 | \alias{row_cells} 8 | \alias{row_cells,TableRow-method} 9 | \alias{row_cells<-} 10 | \alias{row_cells<-,TableRow-method} 11 | \alias{row_values} 12 | \alias{row_values,TableRow-method} 13 | \alias{row_values<-} 14 | \alias{row_values<-,TableRow-method} 15 | \alias{row_values<-,LabelRow-method} 16 | \title{Row attribute accessors} 17 | \usage{ 18 | obj_avar(obj) 19 | 20 | \S4method{obj_avar}{TableRow}(obj) 21 | 22 | \S4method{obj_avar}{ElementaryTable}(obj) 23 | 24 | row_cells(obj) 25 | 26 | \S4method{row_cells}{TableRow}(obj) 27 | 28 | row_cells(obj) <- value 29 | 30 | \S4method{row_cells}{TableRow}(obj) <- value 31 | 32 | row_values(obj) 33 | 34 | \S4method{row_values}{TableRow}(obj) 35 | 36 | row_values(obj) <- value 37 | 38 | \S4method{row_values}{TableRow}(obj) <- value 39 | 40 | \S4method{row_values}{LabelRow}(obj) <- value 41 | } 42 | \arguments{ 43 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 44 | 45 | \item{value}{(\code{ANY})\cr the new value.} 46 | } 47 | \value{ 48 | Various return values depending on the accessor called. 49 | } 50 | \description{ 51 | Row attribute accessors 52 | } 53 | -------------------------------------------------------------------------------- /man/row_paths_summary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.R 3 | \name{row_paths_summary} 4 | \alias{row_paths_summary} 5 | \alias{col_paths_summary} 6 | \title{Print row/column paths summary} 7 | \usage{ 8 | row_paths_summary(x) 9 | 10 | col_paths_summary(x) 11 | } 12 | \arguments{ 13 | \item{x}{(\code{VTableTree})\cr an \code{rtable} object.} 14 | } 15 | \value{ 16 | A data frame summarizing the row- or column-structure of \code{x}. 17 | } 18 | \description{ 19 | Print row/column paths summary 20 | } 21 | \examples{ 22 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 23 | ex_adsl_MF <- ex_adsl \%>\% dplyr::filter(SEX \%in\% c("M", "F")) 24 | 25 | lyt <- basic_table() \%>\% 26 | split_cols_by("ARM") \%>\% 27 | split_cols_by("SEX", split_fun = drop_split_levels) \%>\% 28 | analyze(c("AGE", "BMRKR2")) 29 | 30 | tbl <- build_table(lyt, ex_adsl_MF) 31 | tbl 32 | 33 | df <- row_paths_summary(tbl) 34 | df 35 | 36 | col_paths_summary(tbl) 37 | 38 | # manually constructed table 39 | tbl2 <- rtable( 40 | rheader( 41 | rrow( 42 | "row 1", rcell("a", colspan = 2), 43 | rcell("b", colspan = 2) 44 | ), 45 | rrow("h2", "a", "b", "c", "d") 46 | ), 47 | rrow("r1", 1, 2, 1, 2), rrow("r2", 3, 4, 2, 1) 48 | ) 49 | col_paths_summary(tbl2) 50 | \dontshow{\}) # examplesIf} 51 | } 52 | -------------------------------------------------------------------------------- /man/rrow.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compatibility.R 3 | \name{rrow} 4 | \alias{rrow} 5 | \title{Create an \code{rtable} row} 6 | \usage{ 7 | rrow(row.name = "", ..., format = NULL, indent = 0, inset = 0L) 8 | } 9 | \arguments{ 10 | \item{row.name}{(\code{string} or \code{NULL})\cr row name. If \code{NULL}, an empty string is used as \code{row.name} of the 11 | \code{\link[=rrow]{rrow()}}.} 12 | 13 | \item{...}{cell values.} 14 | 15 | \item{format}{(\code{string}, \code{function}, or \code{list})\cr the format label (string) or formatter function to apply to the 16 | cell values passed via \code{...}. See \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for currently supported format labels.} 17 | 18 | \item{indent}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}} 19 | 20 | \item{inset}{(\code{integer(1)})\cr the table inset for the row or table being constructed. See 21 | \code{\link[formatters:table_inset]{formatters::table_inset()}} for details.} 22 | } 23 | \value{ 24 | A row object of the context-appropriate type (label or data). 25 | } 26 | \description{ 27 | Create an \code{rtable} row 28 | } 29 | \examples{ 30 | rrow("ABC", c(1, 2), c(3, 2), format = "xx (xx.\%)") 31 | rrow("") 32 | 33 | } 34 | \seealso{ 35 | Other compatibility: 36 | \code{\link{rheader}()}, 37 | \code{\link{rrowl}()}, 38 | \code{\link{rtable}()} 39 | } 40 | \concept{compatibility} 41 | -------------------------------------------------------------------------------- /man/rrowl.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compatibility.R 3 | \name{rrowl} 4 | \alias{rrowl} 5 | \title{Create an \code{rtable} row from a vector or list of values} 6 | \usage{ 7 | rrowl(row.name, ..., format = NULL, indent = 0, inset = 0L) 8 | } 9 | \arguments{ 10 | \item{row.name}{(\code{string} or \code{NULL})\cr row name. If \code{NULL}, an empty string is used as \code{row.name} of the 11 | \code{\link[=rrow]{rrow()}}.} 12 | 13 | \item{...}{values in vector/list form.} 14 | 15 | \item{format}{(\code{string}, \code{function}, or \code{list})\cr the format label (string) or formatter function to apply to the 16 | cell values passed via \code{...}. See \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for currently supported format labels.} 17 | 18 | \item{indent}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}} 19 | 20 | \item{inset}{(\code{integer(1)})\cr the table inset for the row or table being constructed. See 21 | \code{\link[formatters:table_inset]{formatters::table_inset()}} for details.} 22 | } 23 | \value{ 24 | A row object of the context-appropriate type (label or data). 25 | } 26 | \description{ 27 | Create an \code{rtable} row from a vector or list of values 28 | } 29 | \examples{ 30 | rrowl("a", c(1, 2, 3), format = "xx") 31 | rrowl("a", c(1, 2, 3), c(4, 5, 6), format = "xx") 32 | 33 | 34 | rrowl("N", table(iris$Species)) 35 | rrowl("N", table(iris$Species), format = "xx") 36 | 37 | x <- tapply(iris$Sepal.Length, iris$Species, mean, simplify = FALSE) 38 | 39 | rrow(row.name = "row 1", x) 40 | rrow("ABC", 2, 3) 41 | 42 | rrowl(row.name = "row 1", c(1, 2), c(3, 4)) 43 | rrow(row.name = "row 2", c(1, 2), c(3, 4)) 44 | 45 | } 46 | \seealso{ 47 | Other compatibility: 48 | \code{\link{rheader}()}, 49 | \code{\link{rrow}()}, 50 | \code{\link{rtable}()} 51 | } 52 | \concept{compatibility} 53 | -------------------------------------------------------------------------------- /man/rtables-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/package.R 3 | \docType{package} 4 | \name{rtables-package} 5 | \alias{rtables} 6 | \alias{rtables-package} 7 | \title{rtables: Reporting Tables} 8 | \description{ 9 | Reporting tables often have structure that goes beyond simple rectangular data. The 'rtables' package provides a framework for declaring complex multi-level tabulations and then applying them to data. This framework models both tabulation and the resulting tables as hierarchical, tree-like objects which support sibling sub-tables, arbitrary splitting or grouping of data in row and column dimensions, cells containing multiple values, and the concept of contextual summary computations. A convenient pipe-able interface is provided for declaring table layouts and the corresponding computations, and then applying them to data. 10 | } 11 | \seealso{ 12 | Useful links: 13 | \itemize{ 14 | \item \url{https://github.com/insightsengineering/rtables} 15 | \item \url{https://insightsengineering.github.io/rtables/} 16 | \item Report bugs at \url{https://github.com/insightsengineering/rtables/issues} 17 | } 18 | 19 | } 20 | \author{ 21 | \strong{Maintainer}: Joe Zhu \email{joe.zhu@roche.com} (\href{https://orcid.org/0000-0001-7566-2787}{ORCID}) 22 | 23 | Authors: 24 | \itemize{ 25 | \item Gabriel Becker \email{gabembecker@gmail.com} (Original creator of the package) 26 | \item Adrian Waddell \email{adrian.waddell@gene.com} 27 | \item Davide Garolini \email{davide.garolini@roche.com} (\href{https://orcid.org/0000-0002-1445-1369}{ORCID}) 28 | \item Emily de la Rua \email{emily.de_la_rua@contractors.roche.com} (\href{https://orcid.org/0009-0000-8738-5561}{ORCID}) 29 | } 30 | 31 | Other contributors: 32 | \itemize{ 33 | \item Daniel Sabanés Bové \email{daniel.sabanes_bove@roche.com} [contributor] 34 | \item Maximilian Mordig \email{maximilian_oliver.mordig@roche.com} [contributor] 35 | \item Abinaya Yogasekaram \email{abinaya.yogasekaram@contractors.roche.com} (\href{https://orcid.org/0009-0005-2083-1105}{ORCID}) [contributor] 36 | \item F. Hoffmann-La Roche AG [copyright holder, funder] 37 | } 38 | 39 | } 40 | \keyword{internal} 41 | -------------------------------------------------------------------------------- /man/rtinner.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{simple_analysis} 4 | \alias{simple_analysis} 5 | \alias{simple_analysis,numeric-method} 6 | \alias{simple_analysis,logical-method} 7 | \alias{simple_analysis,factor-method} 8 | \alias{simple_analysis,ANY-method} 9 | \title{Default tabulation} 10 | \usage{ 11 | simple_analysis(x, ...) 12 | 13 | \S4method{simple_analysis}{numeric}(x, ...) 14 | 15 | \S4method{simple_analysis}{logical}(x, ...) 16 | 17 | \S4method{simple_analysis}{factor}(x, ...) 18 | 19 | \S4method{simple_analysis}{ANY}(x, ...) 20 | } 21 | \arguments{ 22 | \item{x}{(\code{vector})\cr the \emph{already split} data being tabulated for a particular cell/set of cells.} 23 | 24 | \item{...}{additional parameters to pass on.} 25 | } 26 | \value{ 27 | A \code{RowsVerticalSection} object (or \code{NULL}). The details of this object should be considered an 28 | internal implementation detail. 29 | } 30 | \description{ 31 | This function is used when \code{\link[=analyze]{analyze()}} is invoked. 32 | } 33 | \details{ 34 | This function has the following behavior given particular types of inputs: 35 | \describe{ 36 | \item{numeric}{calls \code{\link[=mean]{mean()}} on \code{x}.} 37 | \item{logical}{calls \code{\link[=sum]{sum()}} on \code{x}.} 38 | \item{factor}{calls \code{\link[=length]{length()}} on \code{x}.} 39 | } 40 | 41 | The \code{\link[=in_rows]{in_rows()}} function is called on the resulting value(s). All other classes of input currently lead to an error. 42 | } 43 | \examples{ 44 | simple_analysis(1:3) 45 | simple_analysis(iris$Species) 46 | simple_analysis(iris$Species == "setosa") 47 | 48 | } 49 | \author{ 50 | Gabriel Becker and Adrian Waddell 51 | } 52 | -------------------------------------------------------------------------------- /man/sanitize_table_struct.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/validate_table_struct.R 3 | \name{sanitize_table_struct} 4 | \alias{sanitize_table_struct} 5 | \title{Sanitize degenerate table structures} 6 | \usage{ 7 | sanitize_table_struct(tt, empty_msg = "-- This Section Contains No Data --") 8 | } 9 | \arguments{ 10 | \item{tt}{(\code{TableTree})\cr a \code{TableTree} object.} 11 | 12 | \item{empty_msg}{(\code{string})\cr the string which should be spanned across the inserted empty rows.} 13 | } 14 | \value{ 15 | If \code{tt} is already valid, it is returned unmodified. If \code{tt} is degenerate, a modified, non-degenerate 16 | version of the table is returned. 17 | } 18 | \description{ 19 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} 20 | 21 | Experimental function to correct structure of degenerate tables by adding messaging rows to empty sub-structures. 22 | } 23 | \details{ 24 | This function locates degenerate portions of the table (including the table overall in the case of a table with no 25 | data rows) and inserts a row which spans all columns with the message \code{empty_msg} at each one, generating a table 26 | guaranteed to be non-degenerate. 27 | } 28 | \examples{ 29 | sanitize_table_struct(rtable("cool beans")) 30 | 31 | lyt <- basic_table() \%>\% 32 | split_cols_by("ARM") \%>\% 33 | split_rows_by("SEX") \%>\% 34 | summarize_row_groups() 35 | 36 | ## Degenerate because it doesn't have any analyze calls -> no data rows 37 | badtab <- build_table(lyt, DM) 38 | sanitize_table_struct(badtab) 39 | 40 | } 41 | \seealso{ 42 | Other table structure validation functions: 43 | \code{\link{find_degen_struct}()}, 44 | \code{\link{validate_table_struct}()} 45 | } 46 | \concept{table structure validation functions} 47 | -------------------------------------------------------------------------------- /man/score_funs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_sort.R 3 | \name{cont_n_allcols} 4 | \alias{cont_n_allcols} 5 | \alias{cont_n_onecol} 6 | \title{Score functions for sorting \code{TableTrees}} 7 | \usage{ 8 | cont_n_allcols(tt) 9 | 10 | cont_n_onecol(j) 11 | } 12 | \arguments{ 13 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 14 | 15 | \item{j}{(\code{numeric(1)})\cr index of column used for scoring.} 16 | } 17 | \value{ 18 | A single numeric value indicating score according to the relevant metric for \code{tt}, to be used when sorting. 19 | } 20 | \description{ 21 | Score functions for sorting \code{TableTrees} 22 | } 23 | \seealso{ 24 | For examples and details, please read the documentation for \code{\link[=sort_at_path]{sort_at_path()}} and the 25 | \href{https://insightsengineering.github.io/rtables/latest-tag/articles/sorting_pruning.html}{Sorting and Pruning} 26 | vignette. 27 | } 28 | -------------------------------------------------------------------------------- /man/sf_args.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/argument_conventions.R 3 | \name{sf_args} 4 | \alias{sf_args} 5 | \title{Split function argument conventions} 6 | \usage{ 7 | sf_args(trim, label, first) 8 | } 9 | \arguments{ 10 | \item{trim}{(\code{flag})\cr whether splits corresponding with 0 observations should be kept when tabulating.} 11 | 12 | \item{label}{(\code{string})\cr a label (not to be confused with the name) for the object/structure.} 13 | 14 | \item{first}{(\code{flag})\cr whether the created split level should be placed first in the levels (\code{TRUE}) or 15 | last (\code{FALSE}, the default).} 16 | } 17 | \value{ 18 | No return value. 19 | } 20 | \description{ 21 | Split function argument conventions 22 | } 23 | \seealso{ 24 | Other conventions: 25 | \code{\link{compat_args}()}, 26 | \code{\link{constr_args}()}, 27 | \code{\link{gen_args}()}, 28 | \code{\link{lyt_args}()} 29 | } 30 | \concept{conventions} 31 | -------------------------------------------------------------------------------- /man/spl_context.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{spl_context} 4 | \alias{spl_context} 5 | \title{.spl_context within analysis and split functions} 6 | \description{ 7 | \code{.spl_context} is an optional parameter for any of rtables' special functions, i.e. \code{afun} (analysis function 8 | in \code{\link[=analyze]{analyze()}}), \code{cfun} (content or label function in \code{\link[=summarize_row_groups]{summarize_row_groups()}}), or \code{split_fun} (e.g. for 9 | \code{\link[=split_rows_by]{split_rows_by()}}). 10 | } 11 | \details{ 12 | The \code{.spl_context} \code{data.frame} gives information about the subsets of data corresponding to the splits within 13 | which the current \code{analyze} action is nested. Taken together, these correspond to the path that the resulting (set 14 | of) rows the analysis function is creating, although the information is in a slightly different form. Each split 15 | (which correspond to groups of rows in the resulting table), as well as the initial 'root' "split", is represented 16 | via the following columns: 17 | 18 | \describe{ 19 | \item{split}{The name of the split (often the variable being split).} 20 | \item{value}{The string representation of the value at that split (\code{split}).} 21 | \item{full_parent_df}{A \code{data.frame} containing the full data (i.e. across all columns) corresponding to the path 22 | defined by the combination of \code{split} and \code{value} of this row \emph{and all rows above this row}.} 23 | \item{all_cols_n}{The number of observations corresponding to the row grouping (union of all columns).} 24 | \item{column for each column in the table structure (\emph{row-split and analyze contexts only})}{These list columns 25 | (named the same as \code{names(col_exprs(tab))}) contain logical vectors corresponding to the subset of this row's 26 | \code{full_parent_df} corresponding to the column.} 27 | \item{cur_col_id}{Identifier of the current column. This may be an internal name, constructed by pasting the 28 | column path together.} 29 | \item{cur_col_subset}{List column containing logical vectors indicating the subset of this row's \code{full_parent_df} 30 | for the column currently being created by the analysis function.} 31 | \item{cur_col_expr}{List of current column expression. This may be used to filter \code{.alt_df_row}, or any external 32 | data, by column. Filtering \code{.alt_df_row} by columns produces \code{.alt_df}.} 33 | \item{cur_col_n}{Integer column containing the observation counts for that split.} 34 | \item{cur_col_split}{Current column split names. This is recovered from the current column path.} 35 | \item{cur_col_split_val}{Current column split values. This is recovered from the current column path.} 36 | } 37 | } 38 | \note{ 39 | Within analysis functions that accept \code{.spl_context}, the \code{all_cols_n} and \code{cur_col_n} columns of the data frame 40 | will contain the 'true' observation counts corresponding to the row-group and row-group x column subsets of the 41 | data. These numbers will not, and currently cannot, reflect alternate column observation counts provided by the 42 | \code{alt_counts_df}, \code{col_counts} or \code{col_total} arguments to \code{\link[=build_table]{build_table()}}. 43 | } 44 | -------------------------------------------------------------------------------- /man/spl_context_to_disp_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{spl_context_to_disp_path} 4 | \alias{spl_context_to_disp_path} 5 | \title{Translate spl_context to a path to display in error messages} 6 | \usage{ 7 | spl_context_to_disp_path(ctx) 8 | } 9 | \arguments{ 10 | \item{ctx}{(\code{data.frame})\cr the \code{spl_context} data frame where the error occurred.} 11 | } 12 | \value{ 13 | A character string containing a description of the row path corresponding to \code{ctx}. 14 | } 15 | \description{ 16 | Translate spl_context to a path to display in error messages 17 | } 18 | -------------------------------------------------------------------------------- /man/spl_variable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/make_split_fun.R 3 | \name{spl_variable} 4 | \alias{spl_variable} 5 | \alias{spl_variable,VarLevelSplit-method} 6 | \alias{spl_variable,VarDynCutSplit-method} 7 | \alias{spl_variable,VarStaticCutSplit-method} 8 | \alias{spl_variable,Split-method} 9 | \title{Variable associated with a split} 10 | \usage{ 11 | spl_variable(spl) 12 | 13 | \S4method{spl_variable}{VarLevelSplit}(spl) 14 | 15 | \S4method{spl_variable}{VarDynCutSplit}(spl) 16 | 17 | \S4method{spl_variable}{VarStaticCutSplit}(spl) 18 | 19 | \S4method{spl_variable}{Split}(spl) 20 | } 21 | \arguments{ 22 | \item{spl}{(\code{VarLevelSplit})\cr the split object.} 23 | } 24 | \value{ 25 | For splits with a single variable associated with them, returns the split. Otherwise, an error is raised. 26 | } 27 | \description{ 28 | This function is intended for use when writing custom splitting logic. In cases where the split is associated with 29 | a single variable, the name of that variable will be returned. At time of writing this includes splits generated 30 | via the \code{\link[=split_rows_by]{split_rows_by()}}, \code{\link[=split_cols_by]{split_cols_by()}}, \code{\link[=split_rows_by_cuts]{split_rows_by_cuts()}}, \code{\link[=split_cols_by_cuts]{split_cols_by_cuts()}}, 31 | \code{\link[=split_rows_by_cutfun]{split_rows_by_cutfun()}}, and \code{\link[=split_cols_by_cutfun]{split_cols_by_cutfun()}} layout directives. 32 | } 33 | \seealso{ 34 | \code{\link{make_split_fun}} 35 | } 36 | -------------------------------------------------------------------------------- /man/split_cols_by_multivar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colby_constructors.R 3 | \name{split_cols_by_multivar} 4 | \alias{split_cols_by_multivar} 5 | \title{Associate multiple variables with columns} 6 | \usage{ 7 | split_cols_by_multivar( 8 | lyt, 9 | vars, 10 | split_fun = NULL, 11 | varlabels = vars, 12 | varnames = NULL, 13 | nested = TRUE, 14 | extra_args = list(), 15 | show_colcounts = FALSE, 16 | colcount_format = NULL 17 | ) 18 | } 19 | \arguments{ 20 | \item{lyt}{(\code{PreDataTableLayouts})\cr layout object pre-data used for tabulation.} 21 | 22 | \item{vars}{(\code{character})\cr vector of variable names.} 23 | 24 | \item{split_fun}{(\code{function} or \code{NULL})\cr custom splitting function. See \link{custom_split_funs}.} 25 | 26 | \item{varlabels}{(\code{character})\cr vector of labels for \code{vars}.} 27 | 28 | \item{varnames}{(\code{character})\cr vector of names for \code{vars} which will appear in pathing. When \code{vars} are all 29 | unique this will be the variable names. If not, these will be variable names with suffixes as necessary to enforce 30 | uniqueness.} 31 | 32 | \item{nested}{(\code{logical})\cr whether this layout instruction should be applied within the existing layout structure 33 | \emph{if possible} (\code{TRUE}, the default) or as a new top-level element (\code{FALSE}). Ignored if it would nest a split 34 | underneath analyses, which is not allowed.} 35 | 36 | \item{extra_args}{(\code{list})\cr extra arguments to be passed to the tabulation function. Element position in the list 37 | corresponds to the children of this split. Named elements in the child-specific lists are ignored if they do 38 | not match a formal argument of the tabulation function.} 39 | 40 | \item{show_colcounts}{(\code{logical(1)})\cr should column counts be displayed at the level 41 | facets created by this split. Defaults to \code{FALSE}.} 42 | 43 | \item{colcount_format}{(\code{character(1)})\cr if \code{show_colcounts} is \code{TRUE}, the 44 | format which should be used to display column counts for facets generated by 45 | this split. Defaults to \code{"(N=xx)"}.} 46 | } 47 | \value{ 48 | A \code{PreDataTableLayouts} object suitable for passing to further layouting functions, and to \code{\link[=build_table]{build_table()}}. 49 | } 50 | \description{ 51 | In some cases, the variable to be ultimately analyzed is most naturally defined on a column, not a row, basis. 52 | When we need columns to reflect different variables entirely, rather than different levels of a single 53 | variable, we use \code{split_cols_by_multivar}. 54 | } 55 | \examples{ 56 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 57 | library(dplyr) 58 | 59 | ANL <- DM \%>\% mutate(value = rnorm(n()), pctdiff = runif(n())) 60 | 61 | ## toy example where we take the mean of the first variable and the 62 | ## count of >.5 for the second. 63 | colfuns <- list( 64 | function(x) in_rows(mean = mean(x), .formats = "xx.x"), 65 | function(x) in_rows("# x > 5" = sum(x > .5), .formats = "xx") 66 | ) 67 | 68 | lyt <- basic_table() \%>\% 69 | split_cols_by("ARM") \%>\% 70 | split_cols_by_multivar(c("value", "pctdiff")) \%>\% 71 | split_rows_by("RACE", 72 | split_label = "ethnicity", 73 | split_fun = drop_split_levels 74 | ) \%>\% 75 | summarize_row_groups() \%>\% 76 | analyze_colvars(afun = colfuns) 77 | lyt 78 | 79 | tbl <- build_table(lyt, ANL) 80 | tbl 81 | \dontshow{\}) # examplesIf} 82 | } 83 | \seealso{ 84 | \code{\link[=analyze_colvars]{analyze_colvars()}} 85 | } 86 | \author{ 87 | Gabriel Becker 88 | } 89 | -------------------------------------------------------------------------------- /man/subset_cols.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_pos_and_access.R 3 | \name{subset_cols} 4 | \alias{subset_cols} 5 | \alias{subset_cols,TableTree,numeric-method} 6 | \alias{subset_cols,ElementaryTable,numeric-method} 7 | \alias{subset_cols,ANY,character-method} 8 | \alias{subset_cols,TableRow,numeric-method} 9 | \alias{subset_cols,LabelRow,numeric-method} 10 | \alias{subset_cols,InstantiatedColumnInfo,numeric-method} 11 | \alias{subset_cols,LayoutColTree,numeric-method} 12 | \title{Subset a table or row to particular columns} 13 | \usage{ 14 | subset_cols( 15 | tt, 16 | j, 17 | newcinfo = NULL, 18 | keep_topleft = TRUE, 19 | keep_titles = TRUE, 20 | keep_footers = keep_titles, 21 | ... 22 | ) 23 | 24 | \S4method{subset_cols}{TableTree,numeric}( 25 | tt, 26 | j, 27 | newcinfo = NULL, 28 | keep_topleft = TRUE, 29 | keep_titles = TRUE, 30 | keep_footers = keep_titles, 31 | ... 32 | ) 33 | 34 | \S4method{subset_cols}{ElementaryTable,numeric}( 35 | tt, 36 | j, 37 | newcinfo = NULL, 38 | keep_topleft = TRUE, 39 | keep_titles = TRUE, 40 | keep_footers = keep_titles, 41 | ... 42 | ) 43 | 44 | \S4method{subset_cols}{ANY,character}( 45 | tt, 46 | j, 47 | newcinfo = NULL, 48 | keep_topleft = TRUE, 49 | keep_titles = TRUE, 50 | keep_footers = keep_titles, 51 | ... 52 | ) 53 | 54 | \S4method{subset_cols}{TableRow,numeric}( 55 | tt, 56 | j, 57 | newcinfo = NULL, 58 | keep_topleft = TRUE, 59 | keep_titles = TRUE, 60 | keep_footers = keep_titles, 61 | ... 62 | ) 63 | 64 | \S4method{subset_cols}{LabelRow,numeric}( 65 | tt, 66 | j, 67 | newcinfo = NULL, 68 | keep_topleft = TRUE, 69 | keep_titles = TRUE, 70 | keep_footers = keep_titles, 71 | ... 72 | ) 73 | 74 | \S4method{subset_cols}{InstantiatedColumnInfo,numeric}( 75 | tt, 76 | j, 77 | newcinfo = NULL, 78 | keep_topleft = TRUE, 79 | keep_titles = TRUE, 80 | keep_footers = keep_titles, 81 | ... 82 | ) 83 | 84 | \S4method{subset_cols}{LayoutColTree,numeric}( 85 | tt, 86 | j, 87 | newcinfo = NULL, 88 | keep_topleft = TRUE, 89 | keep_titles = TRUE, 90 | keep_footers = keep_titles, 91 | ... 92 | ) 93 | } 94 | \arguments{ 95 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 96 | 97 | \item{j}{(\code{integer}, \code{logical} or \code{character})\cr The column(s) to subset \code{tt} 98 | down to. Character vectors are interpreted as a \emph{column path}, not as names. 99 | Path can include \code{"*"} wildcards.} 100 | 101 | \item{newcinfo}{(\code{NULL} or \code{InstantiatedColumnInfo})\cr The new column info, 102 | if precomputed. Generally should not be manually set by users.} 103 | 104 | \item{keep_topleft}{(\code{flag})\cr if \code{TRUE} (the default), top_left material for the table will be carried over to the 105 | subset.} 106 | 107 | \item{keep_titles}{(\code{flag})\cr if \code{TRUE} (the default), all title material for the table will be carried over to the 108 | subset.} 109 | 110 | \item{keep_footers}{(\code{flag})\cr if \code{TRUE}, all footer material for the table will be carried over to the subset. It 111 | defaults to \code{keep_titles}.} 112 | 113 | \item{...}{Ignored.} 114 | } 115 | \description{ 116 | Subset a table or row to particular columns 117 | } 118 | \examples{ 119 | lyt <- basic_table( 120 | title = "Title", 121 | subtitles = c("Sub", "titles"), 122 | prov_footer = "prov footer", 123 | main_footer = "main footer" 124 | ) \%>\% 125 | split_cols_by("ARM") \%>\% 126 | split_cols_by("SEX") \%>\% 127 | analyze(c("AGE")) 128 | 129 | tbl <- build_table(lyt, DM) 130 | 131 | subset_cols(tbl, c(1, 3)) 132 | subset_cols(tbl, c("ARM", "*", "SEX", "F")) 133 | } 134 | -------------------------------------------------------------------------------- /man/table_shell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_toString.R 3 | \name{table_shell} 4 | \alias{table_shell} 5 | \alias{table_shell_str} 6 | \title{Table shells} 7 | \usage{ 8 | table_shell( 9 | tt, 10 | widths = NULL, 11 | col_gap = 3, 12 | hsep = default_hsep(), 13 | tf_wrap = FALSE, 14 | max_width = NULL 15 | ) 16 | 17 | table_shell_str( 18 | tt, 19 | widths = NULL, 20 | col_gap = 3, 21 | hsep = default_hsep(), 22 | tf_wrap = FALSE, 23 | max_width = NULL 24 | ) 25 | } 26 | \arguments{ 27 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 28 | 29 | \item{widths}{(\code{numeric} or \code{NULL})\cr Proposed widths for the columns of \code{x}. The expected 30 | length of this numeric vector can be retrieved with \code{ncol(x) + 1} as the column of row names 31 | must also be considered.} 32 | 33 | \item{col_gap}{(\code{numeric(1)})\cr space (in characters) between columns.} 34 | 35 | \item{hsep}{(\code{string})\cr character to repeat to create header/body separator line. If 36 | \code{NULL}, the object value will be used. If \code{" "}, an empty separator will be printed. See 37 | \code{\link[formatters:default_hsep]{default_hsep()}} for more information.} 38 | 39 | \item{tf_wrap}{(\code{flag})\cr whether the text for title, subtitles, and footnotes should be wrapped.} 40 | 41 | \item{max_width}{(\code{integer(1)}, \code{string} or \code{NULL})\cr width that title and footer (including 42 | footnotes) materials should be word-wrapped to. If \code{NULL}, it is set to the current print width of the 43 | session (\code{getOption("width")}). If set to \code{"auto"}, the width of the table (plus any table inset) is 44 | used. Parameter is ignored if \code{tf_wrap = FALSE}.} 45 | } 46 | \value{ 47 | \itemize{ 48 | \item \code{table_shell} returns \code{NULL}, as the function is called for the side effect of printing the shell to the console. 49 | \item \code{table_shell_str} returns the string representing the table shell. 50 | } 51 | } 52 | \description{ 53 | A table shell is a rendering of the table which maintains the structure, but does not display the values, rather 54 | displaying the formatting instructions for each cell. 55 | } 56 | \examples{ 57 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 58 | library(dplyr) 59 | 60 | iris2 <- iris \%>\% 61 | group_by(Species) \%>\% 62 | mutate(group = as.factor(rep_len(c("a", "b"), length.out = n()))) \%>\% 63 | ungroup() 64 | 65 | lyt <- basic_table() \%>\% 66 | split_cols_by("Species") \%>\% 67 | split_cols_by("group") \%>\% 68 | analyze(c("Sepal.Length", "Petal.Width"), afun = list_wrap_x(summary), format = "xx.xx") 69 | 70 | tbl <- build_table(lyt, iris2) 71 | table_shell(tbl) 72 | \dontshow{\}) # examplesIf} 73 | } 74 | \seealso{ 75 | \code{\link[=value_formats]{value_formats()}} for a matrix of formats for each cell in a table. 76 | } 77 | -------------------------------------------------------------------------------- /man/table_structure.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.R 3 | \name{table_structure} 4 | \alias{table_structure} 5 | \title{Summarize table} 6 | \usage{ 7 | table_structure(x, detail = c("subtable", "row")) 8 | } 9 | \arguments{ 10 | \item{x}{(\code{VTableTree})\cr a table object.} 11 | 12 | \item{detail}{(\code{string})\cr either \code{row} or \code{subtable}.} 13 | } 14 | \value{ 15 | No return value. Called for the side-effect of printing a row- or subtable-structure summary of \code{x}. 16 | } 17 | \description{ 18 | Summarize table 19 | } 20 | \examples{ 21 | \dontshow{if (require(dplyr)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 22 | library(dplyr) 23 | 24 | iris2 <- iris \%>\% 25 | group_by(Species) \%>\% 26 | mutate(group = as.factor(rep_len(c("a", "b"), length.out = n()))) \%>\% 27 | ungroup() 28 | 29 | lyt <- basic_table() \%>\% 30 | split_cols_by("Species") \%>\% 31 | split_cols_by("group") \%>\% 32 | analyze(c("Sepal.Length", "Petal.Width"), 33 | afun = list_wrap_x(summary), 34 | format = "xx.xx" 35 | ) 36 | 37 | tbl <- build_table(lyt, iris2) 38 | tbl 39 | 40 | row_paths(tbl) 41 | 42 | table_structure(tbl) 43 | 44 | table_structure(tbl, detail = "row") 45 | \dontshow{\}) # examplesIf} 46 | } 47 | -------------------------------------------------------------------------------- /man/top_left.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{top_left} 4 | \alias{top_left} 5 | \alias{top_left,VTableTree-method} 6 | \alias{top_left,InstantiatedColumnInfo-method} 7 | \alias{top_left,PreDataTableLayouts-method} 8 | \alias{top_left<-} 9 | \alias{top_left<-,VTableTree-method} 10 | \alias{top_left<-,InstantiatedColumnInfo-method} 11 | \alias{top_left<-,PreDataTableLayouts-method} 12 | \title{Top left material} 13 | \usage{ 14 | top_left(obj) 15 | 16 | \S4method{top_left}{VTableTree}(obj) 17 | 18 | \S4method{top_left}{InstantiatedColumnInfo}(obj) 19 | 20 | \S4method{top_left}{PreDataTableLayouts}(obj) 21 | 22 | top_left(obj) <- value 23 | 24 | \S4method{top_left}{VTableTree}(obj) <- value 25 | 26 | \S4method{top_left}{InstantiatedColumnInfo}(obj) <- value 27 | 28 | \S4method{top_left}{PreDataTableLayouts}(obj) <- value 29 | } 30 | \arguments{ 31 | \item{obj}{(\code{ANY})\cr the object for the accessor to access or modify.} 32 | 33 | \item{value}{(\code{ANY})\cr the new value.} 34 | } 35 | \value{ 36 | A character vector representing the top-left material of \code{obj} (or \code{obj} after modification, in the 37 | case of the setter). 38 | } 39 | \description{ 40 | A \code{TableTree} object can have \emph{top left material} which is a sequence of strings which are printed in the 41 | area of the table between the column header display and the label of the first row. These functions access 42 | and modify that material. 43 | } 44 | -------------------------------------------------------------------------------- /man/tree_children.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{tree_children} 4 | \alias{tree_children} 5 | \alias{tree_children<-} 6 | \title{Retrieve or set the direct children of a tree-style object} 7 | \usage{ 8 | tree_children(x) 9 | 10 | tree_children(x) <- value 11 | } 12 | \arguments{ 13 | \item{x}{(\code{TableTree} or \code{ElementaryTable})\cr an object with a tree structure.} 14 | 15 | \item{value}{(\code{list})\cr new list of children.} 16 | } 17 | \value{ 18 | A list of direct children of \code{x}. 19 | } 20 | \description{ 21 | Retrieve or set the direct children of a tree-style object 22 | } 23 | -------------------------------------------------------------------------------- /man/trim_levels_in_facets.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/make_split_fun.R 3 | \name{trim_levels_in_facets} 4 | \alias{trim_levels_in_facets} 5 | \title{Trim levels of another variable from each facet (post-processing split step)} 6 | \usage{ 7 | trim_levels_in_facets(innervar) 8 | } 9 | \arguments{ 10 | \item{innervar}{(\code{character})\cr the variable(s) to trim (remove unobserved levels) independently within each facet.} 11 | } 12 | \value{ 13 | A function suitable for use in the \code{pre} (list) argument of \code{make_split_fun}. 14 | } 15 | \description{ 16 | Trim levels of another variable from each facet (post-processing split step) 17 | } 18 | \seealso{ 19 | \code{\link[=make_split_fun]{make_split_fun()}} 20 | 21 | Other make_custom_split: 22 | \code{\link{add_combo_facet}()}, 23 | \code{\link{drop_facet_levels}()}, 24 | \code{\link{make_split_fun}()}, 25 | \code{\link{make_split_result}()} 26 | } 27 | \concept{make_custom_split} 28 | -------------------------------------------------------------------------------- /man/trim_levels_to_map.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/default_split_funs.R 3 | \name{trim_levels_to_map} 4 | \alias{trim_levels_to_map} 5 | \title{Trim levels to map} 6 | \usage{ 7 | trim_levels_to_map(map = NULL) 8 | } 9 | \arguments{ 10 | \item{map}{data.frame. A data.frame defining allowed combinations of 11 | variables. Any combination at the level of this split not present in the 12 | map will be removed from the data, both for the variable being split and 13 | those present in the data but not associated with this split or any parents 14 | of it.} 15 | } 16 | \value{ 17 | A function that can be used as a split function. 18 | } 19 | \description{ 20 | This split function constructor creates a split function which trims levels of a variable to reflect restrictions 21 | on the possible combinations of two or more variables which the data is split by (along the same axis) within a 22 | layout. 23 | } 24 | \details{ 25 | When splitting occurs, the map is subset to the values of all previously performed splits. The levels of the 26 | variable being split are then pruned to only those still present within this subset of the map representing the 27 | current hierarchical splitting context. 28 | 29 | Splitting is then performed via the \code{\link[=keep_split_levels]{keep_split_levels()}} split function. 30 | 31 | Each resulting element of the partition is then further trimmed by pruning values of any remaining variables 32 | specified in the map to those values allowed under the combination of the previous and current split. 33 | } 34 | \examples{ 35 | map <- data.frame( 36 | LBCAT = c("CHEMISTRY", "CHEMISTRY", "CHEMISTRY", "IMMUNOLOGY"), 37 | PARAMCD = c("ALT", "CRP", "CRP", "IGA"), 38 | ANRIND = c("LOW", "LOW", "HIGH", "HIGH"), 39 | stringsAsFactors = FALSE 40 | ) 41 | 42 | lyt <- basic_table() \%>\% 43 | split_rows_by("LBCAT") \%>\% 44 | split_rows_by("PARAMCD", split_fun = trim_levels_to_map(map = map)) \%>\% 45 | analyze("ANRIND") 46 | tbl <- build_table(lyt, ex_adlb) 47 | 48 | } 49 | \seealso{ 50 | \code{\link[=trim_levels_in_group]{trim_levels_in_group()}}. 51 | } 52 | -------------------------------------------------------------------------------- /man/trim_rows.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_compare_tables.R 3 | \name{trim_rows} 4 | \alias{trim_rows} 5 | \title{Trim rows from a populated table without regard for table structure} 6 | \usage{ 7 | trim_rows(tt, criteria = all_zero_or_na) 8 | } 9 | \arguments{ 10 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 11 | 12 | \item{criteria}{(\code{function})\cr function which takes a \code{TableRow} object and returns \code{TRUE} if that row 13 | should be removed. Defaults to \code{\link[=all_zero_or_na]{all_zero_or_na()}}.} 14 | } 15 | \value{ 16 | The table with rows that have only \code{NA} or 0 cell values removed. 17 | } 18 | \description{ 19 | Trim rows from a populated table without regard for table structure 20 | } 21 | \details{ 22 | This function will be deprecated in the future in favor of the more elegant and versatile \code{\link[=prune_table]{prune_table()}} 23 | function which can perform the same function as \code{trim_rows()} but is more powerful as it takes table structure 24 | into account. 25 | } 26 | \note{ 27 | Visible \code{LabelRow}s are including in this trimming, which can lead to either all label rows being trimmed or 28 | label rows remaining when all data rows have been trimmed, depending on what \code{criteria} returns when called on 29 | a \code{LabelRow} object. To avoid this, use the structurally-aware \code{\link[=prune_table]{prune_table()}} machinery instead. 30 | } 31 | \examples{ 32 | adsl <- ex_adsl 33 | levels(adsl$SEX) <- c(levels(ex_adsl$SEX), "OTHER") 34 | 35 | tbl_to_trim <- basic_table() \%>\% 36 | analyze("BMRKR1") \%>\% 37 | split_cols_by("ARM") \%>\% 38 | split_rows_by("SEX") \%>\% 39 | summarize_row_groups() \%>\% 40 | split_rows_by("STRATA1") \%>\% 41 | summarize_row_groups() \%>\% 42 | analyze("AGE") \%>\% 43 | build_table(adsl) 44 | 45 | tbl_to_trim \%>\% trim_rows() 46 | 47 | tbl_to_trim \%>\% trim_rows(all_zero) 48 | 49 | } 50 | \seealso{ 51 | \code{\link[=prune_table]{prune_table()}} 52 | } 53 | -------------------------------------------------------------------------------- /man/tsv_io.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_export.R 3 | \name{export_as_tsv} 4 | \alias{export_as_tsv} 5 | \alias{import_from_tsv} 6 | \title{Create enriched flat value table with paths} 7 | \usage{ 8 | export_as_tsv( 9 | tt, 10 | file = NULL, 11 | path_fun = collapse_path, 12 | value_fun = collapse_values, 13 | sep = "\\t", 14 | ... 15 | ) 16 | 17 | import_from_tsv(file) 18 | } 19 | \arguments{ 20 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 21 | 22 | \item{file}{(\code{string})\cr the path of the file to written to or read from.} 23 | 24 | \item{path_fun}{(\code{function})\cr function to transform paths into single-string row/column names.} 25 | 26 | \item{value_fun}{(\code{function})\cr function to transform cell values into cells of a \code{data.frame}. Defaults to 27 | \code{collapse_values}, which creates strings where multi-valued cells are collapsed together, separated by \code{|}.} 28 | 29 | \item{sep}{(\code{string})\cr defaults to \verb{\\t}. See \code{\link[utils:write.table]{utils::write.table()}} for more details.} 30 | 31 | \item{...}{(\code{any})\cr additional arguments to be passed to \code{\link[utils:write.table]{utils::write.table()}}.} 32 | } 33 | \value{ 34 | \itemize{ 35 | \item \code{export_as_tsv} returns \code{NULL} silently. 36 | \item \code{import_from_tsv} returns a \code{data.frame} with re-constituted list values. 37 | } 38 | } 39 | \description{ 40 | This function creates a flat tabular file of cell values and corresponding paths via \code{\link[=path_enriched_df]{path_enriched_df()}}. It then 41 | writes that data frame out as a \code{tsv} file. 42 | } 43 | \details{ 44 | By default (i.e. when \code{value_func} is not specified, list columns where at least one value has length > 1 are 45 | collapsed to character vectors by collapsing the list element with \code{"|"}. 46 | } 47 | \note{ 48 | There is currently no round-trip capability for this type of export. You can read values exported this way back in 49 | via \code{import_from_tsv} but you will receive only the \code{data.frame} version back, NOT a \code{TableTree}. 50 | } 51 | \seealso{ 52 | \code{\link[=path_enriched_df]{path_enriched_df()}} for the underlying function that does the work. 53 | } 54 | -------------------------------------------------------------------------------- /man/ttap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tt_pos_and_access.R 3 | \name{tt_at_path} 4 | \alias{tt_at_path} 5 | \alias{tt_at_path<-} 6 | \title{Access or set table elements at specified path} 7 | \usage{ 8 | tt_at_path(tt, path, ...) 9 | 10 | tt_at_path(tt, path, ...) <- value 11 | } 12 | \arguments{ 13 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 14 | 15 | \item{path}{(\code{character})\cr a vector path for a position within the structure of a \code{TableTree}. Each element 16 | represents a subsequent choice amongst the children of the previous choice.} 17 | 18 | \item{...}{unused.} 19 | 20 | \item{value}{(\code{ANY})\cr the new value.} 21 | } 22 | \description{ 23 | Access or set table elements at specified path 24 | } 25 | \note{ 26 | Setting \code{NULL} at a defined path removes the corresponding sub-table. 27 | } 28 | \examples{ 29 | # Accessing sub table. 30 | lyt <- basic_table() \%>\% 31 | split_cols_by("ARM") \%>\% 32 | split_rows_by("SEX") \%>\% 33 | split_rows_by("BMRKR2") \%>\% 34 | analyze("AGE") 35 | 36 | tbl <- build_table(lyt, ex_adsl) \%>\% prune_table() 37 | sub_tbl <- tt_at_path(tbl, path = c("SEX", "F", "BMRKR2")) 38 | 39 | # Removing sub table. 40 | tbl2 <- tbl 41 | tt_at_path(tbl2, path = c("SEX", "F")) <- NULL 42 | tbl2 43 | 44 | # Setting sub table. 45 | lyt3 <- basic_table() \%>\% 46 | split_cols_by("ARM") \%>\% 47 | split_rows_by("SEX") \%>\% 48 | analyze("BMRKR2") 49 | 50 | tbl3 <- build_table(lyt3, ex_adsl) \%>\% prune_table() 51 | 52 | tt_at_path(tbl3, path = c("SEX", "F", "BMRKR2")) <- sub_tbl 53 | tbl3 54 | 55 | } 56 | -------------------------------------------------------------------------------- /man/update_ref_indexing.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/index_footnotes.R 3 | \name{update_ref_indexing} 4 | \alias{update_ref_indexing} 5 | \title{Update footnote indices on a built table} 6 | \usage{ 7 | update_ref_indexing(tt) 8 | } 9 | \arguments{ 10 | \item{tt}{(\code{TableTree} or related class)\cr a \code{TableTree} object representing a populated table.} 11 | } 12 | \description{ 13 | Re-indexes footnotes within a built table. 14 | } 15 | \details{ 16 | After adding or removing referential footnotes manually, or after subsetting a table, the reference indexes 17 | (i.e. the number associated with specific footnotes) may be incorrect. This function recalculates these based 18 | on the full table. 19 | } 20 | \note{ 21 | In the future this should not generally need to be called manually. 22 | } 23 | -------------------------------------------------------------------------------- /man/validate_table_struct.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/validate_table_struct.R 3 | \name{validate_table_struct} 4 | \alias{validate_table_struct} 5 | \alias{assert_valid_table} 6 | \title{Validate and assert valid table structure} 7 | \usage{ 8 | validate_table_struct(tt) 9 | 10 | assert_valid_table(tt, warn_only = FALSE) 11 | } 12 | \arguments{ 13 | \item{tt}{(\code{TableTree})\cr a \code{TableTree} object.} 14 | 15 | \item{warn_only}{(\code{flag})\cr whether a warning should be thrown instead of an error. Defaults to \code{FALSE}.} 16 | } 17 | \value{ 18 | \itemize{ 19 | \item \code{validate_table_struct} returns a logical value indicating valid structure. 20 | \item \code{assert_valid_table} is called for its side-effect of throwing an error or warning for degenerate tables. 21 | } 22 | } 23 | \description{ 24 | \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} 25 | 26 | A \code{TableTree} (\code{rtables}-built table) is considered degenerate if: 27 | \enumerate{ 28 | \item{It contains no subtables or data rows (content rows do not count).} 29 | \item{It contains a subtable which is degenerate by the criterion above.} 30 | } 31 | 32 | \code{validate_table_struct} assesses whether \code{tt} has a valid (non-degenerate) structure. 33 | 34 | \code{assert_valid_table} asserts a table must have a valid structure, and throws an informative error (the default) or 35 | warning (if \code{warn_only} is \code{TRUE}) if the table is degenerate (has invalid structure or contains one or more 36 | invalid substructures. 37 | } 38 | \note{ 39 | This function is experimental and the exact text of the warning/error is subject to change in future releases. 40 | } 41 | \examples{ 42 | validate_table_struct(rtable("hahaha")) 43 | \dontrun{ 44 | assert_valid_table(rtable("oops")) 45 | } 46 | 47 | } 48 | \seealso{ 49 | Other table structure validation functions: 50 | \code{\link{find_degen_struct}()}, 51 | \code{\link{sanitize_table_struct}()} 52 | } 53 | \concept{table structure validation functions} 54 | -------------------------------------------------------------------------------- /man/value_formats.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{value_formats} 4 | \alias{value_formats} 5 | \alias{value_formats,ANY-method} 6 | \alias{value_formats,TableRow-method} 7 | \alias{value_formats,LabelRow-method} 8 | \alias{value_formats,VTableTree-method} 9 | \title{Value formats} 10 | \usage{ 11 | value_formats(obj, default = obj_format(obj)) 12 | 13 | \S4method{value_formats}{ANY}(obj, default = obj_format(obj)) 14 | 15 | \S4method{value_formats}{TableRow}(obj, default = obj_format(obj)) 16 | 17 | \S4method{value_formats}{LabelRow}(obj, default = obj_format(obj)) 18 | 19 | \S4method{value_formats}{VTableTree}(obj, default = obj_format(obj)) 20 | } 21 | \arguments{ 22 | \item{obj}{(\code{VTableTree} or \code{TableRow})\cr a table or row object.} 23 | 24 | \item{default}{(\code{string}, \code{function}, or \code{list})\cr default format.} 25 | } 26 | \value{ 27 | Matrix (storage mode list) containing the effective format for each cell position in the table 28 | (including 'virtual' cells implied by label rows, whose formats are always \code{NULL}). 29 | } 30 | \description{ 31 | Returns a matrix of formats for the cells in a table. 32 | } 33 | \examples{ 34 | lyt <- basic_table() \%>\% 35 | split_rows_by("RACE", split_fun = keep_split_levels(c("ASIAN", "WHITE"))) \%>\% 36 | analyze("AGE") 37 | 38 | tbl <- build_table(lyt, DM) 39 | value_formats(tbl) 40 | 41 | } 42 | \seealso{ 43 | \code{\link[=table_shell]{table_shell()}} and \code{\link[=table_shell_str]{table_shell_str()}} for information on the table format structure. 44 | } 45 | -------------------------------------------------------------------------------- /man/vil.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tree_accessors.R 3 | \name{vars_in_layout} 4 | \alias{vars_in_layout} 5 | \alias{vars_in_layout,PreDataTableLayouts-method} 6 | \alias{vars_in_layout,PreDataAxisLayout-method} 7 | \alias{vars_in_layout,SplitVector-method} 8 | \alias{vars_in_layout,Split-method} 9 | \alias{vars_in_layout,CompoundSplit-method} 10 | \alias{vars_in_layout,ManualSplit-method} 11 | \title{List variables required by a pre-data table layout} 12 | \usage{ 13 | vars_in_layout(lyt) 14 | 15 | \S4method{vars_in_layout}{PreDataTableLayouts}(lyt) 16 | 17 | \S4method{vars_in_layout}{PreDataAxisLayout}(lyt) 18 | 19 | \S4method{vars_in_layout}{SplitVector}(lyt) 20 | 21 | \S4method{vars_in_layout}{Split}(lyt) 22 | 23 | \S4method{vars_in_layout}{CompoundSplit}(lyt) 24 | 25 | \S4method{vars_in_layout}{ManualSplit}(lyt) 26 | } 27 | \arguments{ 28 | \item{lyt}{(\code{PreDataTableLayouts})\cr the layout (or a component thereof).} 29 | } 30 | \value{ 31 | A character vector containing the unique variables explicitly used in the layout (see the notes below). 32 | } 33 | \description{ 34 | List variables required by a pre-data table layout 35 | } 36 | \details{ 37 | This will walk the layout declaration and return a vector of the names of the unique variables that are used 38 | in any of the following ways: 39 | \itemize{ 40 | \item Variable being split on (directly or via cuts) 41 | \item Element of a Multi-variable column split 42 | \item Content variable 43 | \item Value-label variable 44 | } 45 | } 46 | \note{ 47 | \itemize{ 48 | \item This function will not detect dependencies implicit in analysis or summary functions which accept \code{x} 49 | or \code{df} and then rely on the existence of particular variables not being split on/analyzed. 50 | \item The order these variable names appear within the return vector is undefined and should not be relied upon. 51 | } 52 | } 53 | \examples{ 54 | lyt <- basic_table() \%>\% 55 | split_cols_by("ARM") \%>\% 56 | split_cols_by("SEX") \%>\% 57 | summarize_row_groups(label_fstr = "Overall (N)") \%>\% 58 | split_rows_by("RACE", 59 | split_label = "Ethnicity", labels_var = "ethn_lab", 60 | split_fun = drop_split_levels 61 | ) \%>\% 62 | summarize_row_groups("RACE", label_fstr = "\%s (n)") \%>\% 63 | analyze("AGE", var_labels = "Age", afun = mean, format = "xx.xx") 64 | 65 | vars_in_layout(lyt) 66 | 67 | } 68 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /revdep/.gitignore: -------------------------------------------------------------------------------- 1 | checks 2 | library 3 | checks.noindex 4 | library.noindex 5 | cloud.noindex 6 | data.sqlite 7 | *.html 8 | -------------------------------------------------------------------------------- /rtables.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: 48dc223c-890c-42ad-aba5-531d1612466b 3 | 4 | RestoreWorkspace: Default 5 | SaveWorkspace: Default 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: Sweave 14 | LaTeX: pdfLaTeX 15 | 16 | BuildType: Package 17 | PackageUseDevtools: Yes 18 | PackageInstallArgs: --no-multiarch --with-keep.source 19 | PackageRoxygenize: rd,collate,namespace 20 | 21 | UseNativePipeOperator: No 22 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | if (requireNamespace("testthat", quietly = TRUE)) { 2 | library(testthat) 3 | library(rtables) 4 | test_check("rtables", reporter = "check") 5 | } 6 | -------------------------------------------------------------------------------- /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-colby_constructors.R: -------------------------------------------------------------------------------- 1 | test_that("analyze's var_labels accepts a vector of length 1 consisting of a single NA", { 2 | testthat::expect_no_error( 3 | basic_table() %>% 4 | split_cols_by("ARM") %>% 5 | analyze("AGE", var_labels = c(AGE = NA)) 6 | ) 7 | }) 8 | -------------------------------------------------------------------------------- /tests/testthat/test-compare_rtables.R: -------------------------------------------------------------------------------- 1 | test_that("compare_rtables", { 2 | lyt <- make_big_lyt() 3 | 4 | ## hack to force all counts to "happen to be different" 5 | dat <- rawdat[-which(rawdat$ARM == "ARM2")[1:9], ] 6 | tab <- build_table(lyt, dat) 7 | cmp <- compare_rtables(tab, tab) 8 | expect_true(all(cmp == ".")) 9 | 10 | cmp_no4col <- compare_rtables(tab, tab[, -4]) 11 | expect_true(all(cmp_no4col[, 4] == "+")) 12 | expect_true(all(cmp_no4col[, 1:3] == ".")) 13 | 14 | rdf <- make_row_df(tab) 15 | ## its not smart enought o shift columns yet... 16 | ## tol = .01 need for the medians to be different 17 | cmp_no3col <- compare_rtables(tab[, -3], tab, tol = .01) 18 | expect_true(all(cmp_no3col[, 1:2] == ".")) 19 | 20 | ## not checking ContentRows because of unfortunate identical counts in cols 3 and 4 :( 21 | expect_true(all(cmp_no3col[rdf$node_class != "LabelRow", 3] == "X")) 22 | expect_true(all(cmp_no3col[, 4] == "-")) 23 | cmp_no3colb <- compare_rtables(tab[, -3], tab, structure = TRUE) 24 | expect_true(all(cmp_no3colb[, 1:2] == ".")) 25 | expect_true(all(cmp_no3colb[, 3] == "C")) 26 | expect_true(all(cmp_no3colb[, 4] == "-")) 27 | 28 | cmp_bothsubset <- compare_rtables(tab[-5, ], tab[, -2], tol = .01) 29 | 30 | expect_true(all(cmp_bothsubset[28, ] == "-")) 31 | expect_true(all(cmp_bothsubset[-28, 4] == "+")) 32 | expect_true(all(cmp_bothsubset[5:28, ] != ".")) 33 | 34 | stupid_cmp <- compare_rtables(tab, tab[, -1], tol = 1e5) 35 | expect_true(all(stupid_cmp[, 1:3] == ".")) 36 | }) 37 | -------------------------------------------------------------------------------- /tests/testthat/test-deprecated.R: -------------------------------------------------------------------------------- 1 | context("deprecated functionality") 2 | 3 | 4 | test_that("deprecated things are still there and work kinda", { 5 | lifecycle::expect_deprecated(lyt11 <- split_cols_by(lyt = NULL, "ARM")) 6 | expect_identical(lyt11, basic_table() %>% split_cols_by("ARM")) 7 | lifecycle::expect_deprecated(lyt22 <- split_rows_by(lyt = NULL, "ARM")) 8 | expect_identical(lyt22, basic_table() %>% split_rows_by("ARM")) 9 | }) 10 | 11 | test_that("deprecated insert_rrow still currently works", { 12 | tbl <- basic_table() %>% 13 | split_cols_by("Species") %>% 14 | analyze("Sepal.Length") %>% 15 | build_table(iris) 16 | 17 | lifecycle::expect_deprecated(res1 <- insert_rrow(tbl, rrow("Hello World"))) 18 | realdf <- make_row_df(tbl) 19 | o <- options(warn = -1) 20 | mf1 <- matrix_form(res1) 21 | expect_identical(mf1$strings[2, , drop = TRUE], c("Hello World", "", "", "")) 22 | 23 | res2 <- insert_rrow(tbl, rrow("Hello World"), at = 2) 24 | mf2 <- matrix_form(res2) 25 | expect_identical(mf2$strings[3, , drop = TRUE], c("Hello World", "", "", "")) 26 | 27 | tbl2 <- basic_table() %>% 28 | split_cols_by("Species") %>% 29 | split_rows_by("Species") %>% 30 | analyze("Sepal.Length") %>% 31 | build_table(iris) 32 | ## for coverage 33 | res3 <- insert_rrow(tbl2, rrow("Hello World")) 34 | mf3 <- matrix_form(res3) 35 | expect_identical(mf3$strings[2, , drop = TRUE], c("Hello World", "", "", "")) 36 | res4 <- insert_rrow(tbl2, rrow("Hello World"), at = 2) 37 | mf4 <- matrix_form(res4) 38 | expect_identical(mf4$strings[3, , drop = TRUE], c("Hello World", "", "", "")) 39 | 40 | res5 <- insert_rrow(tbl2, rrow("Hello World"), at = 4) 41 | mf5 <- matrix_form(res5) 42 | expect_identical(mf5$strings[5, , drop = TRUE], c("Hello World", "", "", "")) 43 | res6 <- insert_rrow(tbl2, rrow("new row", 5, 6, 7)) 44 | mf6 <- matrix_form(res6) 45 | expect_identical(mf6$strings[2, , drop = TRUE], c("new row", "5", "6", "7")) 46 | res7 <- insert_rrow(tbl2, rrow("new row", 5, 6, 7), at = 3) 47 | mf7 <- matrix_form(res7) 48 | expect_identical(mf7$strings[4, , drop = TRUE], c("new row", "5", "6", "7")) 49 | 50 | options(o) 51 | }) 52 | 53 | test_that("add_colcounts works", { 54 | tbl1 <- basic_table() %>% 55 | add_colcounts() %>% 56 | analyze("AGE") %>% 57 | build_table(DM) 58 | 59 | tbl2 <- basic_table(show_colcounts = TRUE) %>% 60 | analyze("AGE") %>% 61 | build_table(DM) 62 | 63 | expect_true(identical(tbl1, tbl2)) 64 | }) 65 | 66 | test_that("add_colcounts format argument works", { 67 | # 2d count (%) format works 68 | tbl1 <- basic_table() %>% 69 | add_colcounts(format = "xx (xx%)") %>% 70 | split_cols_by("ARM") %>% 71 | build_table(DM) 72 | mf_tbl1_colcounts <- matrix_form(tbl1)$strings[2, ] 73 | expect_identical(mf_tbl1_colcounts, c("", "121 (100%)", "106 (100%)", "129 (100%)")) 74 | 75 | # correct error message for 2d format without % 76 | lyt <- basic_table() %>% 77 | add_colcounts(format = "xx (xx)") %>% 78 | split_cols_by("ARM") 79 | expect_error( 80 | matrix_form(build_table(lyt, DM)), 81 | paste( 82 | "This 2d format is not supported for column counts.", 83 | "Please choose a 1d format or a 2d format that includes a % value." 84 | ) 85 | ) 86 | 87 | # correct error message for 3d colcount format 88 | lyt <- basic_table() %>% 89 | add_colcounts(format = "xx.x (xx.x - xx.x)") %>% 90 | split_cols_by("ARM") 91 | expect_error(matrix_form(build_table(lyt, DM)), "3d formats are not supported for column counts.") 92 | }) 93 | -------------------------------------------------------------------------------- /tests/testthat/test-matrix_form.R: -------------------------------------------------------------------------------- 1 | context("matrix_form works") 2 | 3 | test_that("matrix_form works with indent_rownames = FALSE", { 4 | # Discovered thanks to more stringent indentation checks. See #844 for when it 5 | # surfaced. Cause: make_row_df does not update mf_rinfo indentation if indent_rownames = FALSE 6 | lyt <- basic_table() %>% 7 | split_rows_by("ARM") %>% 8 | analyze("AGE") 9 | tbl <- build_table(lyt, ex_adsl) 10 | mf <- matrix_form(tbl, indent_rownames = FALSE) 11 | expect_equal(mf_rinfo(mf)$indent, rep(0, nrow(tbl))) 12 | expect_silent(out <- toString(mf)) 13 | }) 14 | -------------------------------------------------------------------------------- /tests/testthat/test-sanitize-struct.R: -------------------------------------------------------------------------------- 1 | context("table structure validation") 2 | 3 | test_that("table structure validation and sanitization work", { 4 | bad_dat <- DM 5 | bad_dat$RACE <- NA 6 | bad_lyt1 <- basic_table() %>% 7 | split_cols_by("ARM") %>% 8 | split_rows_by("RACE") %>% 9 | analyze("AGE") 10 | bad_tab1 <- build_table(bad_lyt1, bad_dat) 11 | 12 | expect_identical( 13 | validate_table_struct(bad_tab1), 14 | FALSE 15 | ) 16 | 17 | expect_error( 18 | assert_valid_table(bad_tab1), 19 | "Likely Cause: Empty data" 20 | ) 21 | 22 | san_tab1 <- sanitize_table_struct(bad_tab1) 23 | expect_identical( 24 | cell_values(san_tab1), 25 | list("-- This Section Contains No Data --") 26 | ) 27 | expect_identical( 28 | col_info(san_tab1), 29 | col_info(bad_tab1) 30 | ) 31 | 32 | bad_lyt2 <- basic_table() %>% 33 | split_cols_by("ARM") %>% 34 | split_rows_by("RACE") %>% 35 | split_rows_by("SEX") %>% 36 | summarize_row_groups() 37 | 38 | bad_tab2 <- build_table(bad_lyt2, DM) 39 | expect_error( 40 | assert_valid_table(bad_tab2), 41 | "Cause: Layout did not contain any analyze\\(\\) calls" 42 | ) 43 | 44 | san_tab2 <- sanitize_table_struct(bad_tab2, "my awesome empty msg") 45 | expect_equal( 46 | nrow(san_tab2), 47 | nrow(bad_tab2) + length(levels(DM$RACE)) * length(levels(DM$SEX)) 48 | ) 49 | 50 | expect_equal( 51 | unname(tail(unlist(cell_values(san_tab2)), 1)), 52 | "my awesome empty msg" 53 | ) 54 | }) 55 | -------------------------------------------------------------------------------- /tests/testthat/test-spanning.R: -------------------------------------------------------------------------------- 1 | context("column spanning") 2 | 3 | test_that("column spanning works", { 4 | tbl <- rtable( 5 | header = c("Treatment\nN=100", "Comparison\nN=300", "otherstuff\nN=10"), 6 | format = "xx (xx.xx%)", 7 | rrow("A", c(104, .2), c(100, .4), rcell(15, format = "xx")), 8 | rrow("B", c(23, .4), c(43, .5), rcell(256, format = "xx")), 9 | rrow(), 10 | rrow("this is a very long section header"), 11 | rrow("estimate", rcell(55.23, "xx.xx", colspan = 2), rcell(12, format = "xx")), 12 | rrow("95% CI", indent = 1, rcell(c(44.8, 67.4), format = "(xx.x, xx.x)", colspan = 2), rcell(17, format = "xx")) 13 | ) 14 | 15 | 16 | rws <- collect_leaves(tbl) 17 | 18 | cirow <- tail(rws, 1)[[1]] 19 | 20 | spanned_values <- rtables:::spanned_values 21 | `spanned_values<-` <- rtables:::`spanned_values<-` 22 | 23 | expect_identical(length(spanned_values(cirow)), 3L) 24 | 25 | spanned_values(cirow) <- list(rcell(c(7, 15)), rcell(c(7, 15)), rcell(13, format = "xx")) 26 | 27 | expect_error( 28 | { 29 | spanned_values(cirow) <- list(5, 7, 10) 30 | }, 31 | "Got more than one unique" 32 | ) 33 | 34 | mylrow <- rrow("hiya!!!") 35 | 36 | expect_error( 37 | { 38 | spanned_values(mylrow) <- list(5) 39 | }, 40 | "Label rows can't have non-null" 41 | ) 42 | }) 43 | -------------------------------------------------------------------------------- /tests/testthat/test-structure-summary.R: -------------------------------------------------------------------------------- 1 | context("Summarizing table structure") 2 | 3 | test_that("path summaries", { 4 | lyt <- make_big_lyt() 5 | 6 | tbl <- build_table(lyt, rawdat) 7 | 8 | capture.output(cpathsum <- col_paths_summary(tbl)) 9 | 10 | arm1tmp <- c("ARM", "ARM1") 11 | arm2tmp <- c("ARM", "ARM2") 12 | expect_identical( 13 | cpathsum, 14 | data.frame( 15 | label = c( 16 | "ARM1", "Male", "Female", 17 | "ARM2", "Male", "Female" 18 | ), 19 | path = I(list( 20 | arm1tmp, 21 | c(arm1tmp, c("SEX", "M")), 22 | c(arm1tmp, c("SEX", "F")), 23 | arm2tmp, 24 | c(arm2tmp, c("SEX", "M")), 25 | c(arm2tmp, c("SEX", "F")) 26 | )), 27 | stringsAsFactors = FALSE 28 | ) 29 | ) 30 | 31 | cpval <- col_paths(tbl) 32 | ## cpval doesn't contain the non-leaf paths 33 | expect_identical(cpval, cpathsum$path[-c(1, 4)]) 34 | 35 | capture.output(rpathsum <- row_paths_summary(tbl)) 36 | 37 | ## defined in setup-fakedata.R 38 | expect_identical( 39 | complx_lyt_rnames, 40 | rpathsum$label 41 | ) 42 | 43 | expect_identical( 44 | row_paths(tbl), 45 | rpathsum$path 46 | ) 47 | }) 48 | 49 | test_that("vars_in_layout works", { 50 | lyt <- make_big_lyt() 51 | vars <- vars_in_layout(lyt) 52 | expect_identical( 53 | vars, 54 | c( 55 | "ARM", # split_cols_by 56 | "SEX", # split_cols_by 57 | "gend_label", # split_cols_by labels_var 58 | "RACE", # split_rows_by 59 | "ethn_label", # split_rows_by labels_var 60 | "FACTOR2", # split_rows_by 61 | "fac2_label", # split_rows_by labels_var 62 | "AGE", # analyze 63 | "VAR3" 64 | ) # analyze 65 | ) 66 | 67 | expect_identical( 68 | vars_in_layout(ManualSplit(c("A", "B"), label = "stuff")), 69 | character() 70 | ) 71 | }) 72 | -------------------------------------------------------------------------------- /tests/testthat/test_utils.R: -------------------------------------------------------------------------------- 1 | context("Checking utility functions") 2 | 3 | test_that("func_takes works with different inputs", { 4 | f1 <- function() {} 5 | f2 <- function(df = "a") {} 6 | f3 <- function(x = "df") {} 7 | f4 <- function(x, df) {} 8 | f5 <- function(Df, df = "df") {} 9 | f6 <- function(df1, df = "df") {} 10 | f_l <- list(f1, f2, f3, f4, f5, f6) 11 | 12 | expect_silent(res <- unlist(func_takes(f_l, "df", is_first = TRUE))) 13 | expect_identical(res, c(FALSE, TRUE, FALSE, FALSE, FALSE, FALSE)) 14 | 15 | expect_silent(res <- func_takes(f_l, "df", is_first = FALSE)) 16 | expect_identical( 17 | unlist(res, use.names = FALSE), 18 | c(FALSE, TRUE, FALSE, TRUE, TRUE, TRUE) 19 | ) 20 | 21 | expect_true(all(sapply(res, names) == "df")) 22 | 23 | expect_error( 24 | func_takes(f_l, c("df", "l"), is_first = TRUE), 25 | "is_first works only with one parameters." 26 | ) 27 | }) 28 | -------------------------------------------------------------------------------- /vignettes/images/rtables-basics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/insightsengineering/rtables/c2b5d0baf5ee90b7e7b3a57d4c0e1cedec47f29a/vignettes/images/rtables-basics.png -------------------------------------------------------------------------------- /vignettes/manual_table_construction.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Constructing rtables Manually" 3 | author: "Adrian Waddell" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Constructing rtables Manually} 8 | %\VignetteEncoding{UTF-8} 9 | %\VignetteEngine{knitr::rmarkdown} 10 | editor_options: 11 | chunk_output_type: console 12 | --- 13 | 14 | 15 | ```{r, echo=FALSE} 16 | knitr::opts_chunk$set(comment = "#") 17 | ``` 18 | 19 | ```{css, echo=FALSE} 20 | .reveal .r code { 21 | white-space: pre; 22 | } 23 | ``` 24 | 25 | ## Overview 26 | 27 | The main functions currently associated with `rtable`s are 28 | 29 | Tables in `rtables` can be constructed via the layout or `rtabulate` 30 | tabulation frameworks or also manually. Currently manual table 31 | construction is the only way to define column spans. The main 32 | functions for manual table constructions are: 33 | 34 | * `rtable()`: collection of `rrow()` objects, column header and 35 | default format 36 | * `rrow()`: collection of `rcell()` objects and default format 37 | * `rcell()`: collection of data objects and cell format 38 | 39 | ## Simple Example 40 | 41 | 42 | ```{r, message=FALSE} 43 | library(rtables) 44 | ``` 45 | ```{r} 46 | tbl <- rtable( 47 | header = c("Treatement\nN=100", "Comparison\nN=300"), 48 | format = "xx (xx.xx%)", 49 | rrow("A", c(104, .2), c(100, .4)), 50 | rrow("B", c(23, .4), c(43, .5)), 51 | rrow(), 52 | rrow("this is a very long section header"), 53 | rrow("estimate", rcell(55.23, "xx.xx", colspan = 2)), 54 | rrow("95% CI", indent = 1, rcell(c(44.8, 67.4), format = "(xx.x, xx.x)", colspan = 2)) 55 | ) 56 | ``` 57 | 58 | 59 | Before we go into explaining the individual components used to create 60 | this table we continue with the html conversion of the `rtable()` 61 | object: 62 | 63 | 64 | ```{r} 65 | as_html(tbl, width = "80%") 66 | ``` 67 | 68 | Next, the `[` operator lets you access the cell content. 69 | 70 | ```{r} 71 | tbl[1, 1] 72 | ``` 73 | 74 | and to format that cell run `format_rcell(tbl[1,1])`=`r #format_rcell(tbl[1,1])`. 75 | 76 | Note that `tbl[6, 1]` and `tbl[6, 2]` display both the same `rcell` because of 77 | the `colspan`. 78 | --------------------------------------------------------------------------------