Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #29

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ Suggests:
VignetteBuilder:
knitr,
rmarkdown
Remotes:
insightsengineering/rtables@981_cran_v0.6.11
Config/Needs/verdepcheck: insightsengineering/formatters,
insightsengineering/rtables, tidyverse/magrittr, mllg/checkmate,
rstudio/htmltools, gagolews/stringi, tidymodels/broom, cran/car,
Expand Down
138 changes: 21 additions & 117 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,146 +12,50 @@ knitr::opts_chunk$set(
comment = "#>",
fig.path = "man/figures/README-"
)
suppressPackageStartupMessages(library(rtables.officer))
suppressPackageStartupMessages(library(rtables))
suppressPackageStartupMessages(library(dplyr))
```

# rtables <a href='https://github.com/insightsengineering/rtables'><img src="man/figures/logo.png" align="right" height="200" width="200"/></a>
# rtables.officer <a href='https://github.com/insightsengineering/rtables'><img src="man/figures/logo.png" align="right" height="200" width="200"/></a>

<!-- start badges -->
[![Check 🛠](https://github.com/insightsengineering/rtables/actions/workflows/check.yaml/badge.svg)](https://github.com/insightsengineering/rtables/actions/workflows/check.yaml)
[![Docs 📚](https://github.com/insightsengineering/rtables/actions/workflows/docs.yaml/badge.svg)](https://insightsengineering.github.io/rtables/)
[![Code Coverage 📔](https://raw.githubusercontent.com/insightsengineering/rtables/_xml_coverage_reports/data/main/badge.svg)](https://raw.githubusercontent.com/insightsengineering/rtables/_xml_coverage_reports/data/main/coverage.xml)

![GitHub forks](https://img.shields.io/github/forks/insightsengineering/rtables?style=social)
![GitHub repo stars](https://img.shields.io/github/stars/insightsengineering/rtables?style=social)

![GitHub commit activity](https://img.shields.io/github/commit-activity/m/insightsengineering/rtables)
![GitHub contributors](https://img.shields.io/github/contributors/insightsengineering/rtables)
![GitHub last commit](https://img.shields.io/github/last-commit/insightsengineering/rtables)
![GitHub pull requests](https://img.shields.io/github/issues-pr/insightsengineering/rtables)
![GitHub repo size](https://img.shields.io/github/repo-size/insightsengineering/rtables)
![GitHub language count](https://img.shields.io/github/languages/count/insightsengineering/rtables)
[![Check 🛠](https://github.com/insightsengineering/rtables.officer/actions/workflows/check.yaml/badge.svg)](https://github.com/insightsengineering/rtables.officer/actions/workflows/check.yaml)
[![Docs 📚](https://github.com/insightsengineering/rtables.officer/actions/workflows/docs.yaml/badge.svg)](https://insightsengineering.github.io/rtables.officer/)
[![Code Coverage 📔](https://raw.githubusercontent.com/insightsengineering/rtables.officer/_xml_coverage_reports/data/main/badge.svg)](https://raw.githubusercontent.com/insightsengineering/rtables.officer/_xml_coverage_reports/data/main/coverage.xml)

![GitHub forks](https://img.shields.io/github/forks/insightsengineering/rtables.officer?style=social)
![GitHub repo stars](https://img.shields.io/github/stars/insightsengineering/rtables.officer?style=social)

![GitHub commit activity](https://img.shields.io/github/commit-activity/m/insightsengineering/rtables.officer)
![GitHub contributors](https://img.shields.io/github/contributors/insightsengineering/rtables.officer)
![GitHub last commit](https://img.shields.io/github/last-commit/insightsengineering/rtables.officer)
![GitHub pull requests](https://img.shields.io/github/issues-pr/insightsengineering/rtables.officer)
![GitHub repo size](https://img.shields.io/github/repo-size/insightsengineering/rtables.officer)
![GitHub language count](https://img.shields.io/github/languages/count/insightsengineering/rtables.officer)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Open Issues](https://img.shields.io/github/issues-raw/insightsengineering/rtables?color=red\&label=open%20issues)](https://github.com/insightsengineering/rtables/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
[![Open Issues](https://img.shields.io/github/issues-raw/insightsengineering/rtables.officer?color=red\&label=open%20issues)](https://github.com/insightsengineering/rtables.officer/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)

[![CRAN Version](https://www.r-pkg.org/badges/version/rtables)](https://CRAN.R-project.org/package=rtables)
[![Current Version](https://img.shields.io/github/r-package/v/insightsengineering/rtables/main?color=purple\&label=Development%20Version)](https://github.com/insightsengineering/rtables/tree/main)
[![Current Version](https://img.shields.io/github/r-package/v/insightsengineering/rtables.officer/main?color=purple\&label=Development%20Version)](https://github.com/insightsengineering/rtables.officer/tree/main)
<!-- end badges -->

## Reporting Tables with R

The `rtables` R package was designed to create and display complex tables with R. The cells in an `rtable` may contain
any high-dimensional data structure which can then be displayed with cell-specific formatting instructions. Currently,
`rtables` can be outputted in `ascii` `html`, and `pdf`, as well Power Point (via conversion to `flextable` objects). `rtf` support is in development and will be in a future release.
`rtables` can be outputted in `ascii` `html`, and `pdf`, as well Power Point (via conversion to `flextable` objects). This package `rtables.officer` is designed to support the exporting outputs relate Microsoft office software such as `word` and `powerpoint`.

`rtables` is developed and copy written by `F. Hoffmann-La Roche` and it is released open source under Apache
`rtables` and `rtables.officer` is developed and copy written by `F. Hoffmann-La Roche` and it is released open source under Apache
License Version 2.

`rtables` development is driven by the need to create regulatory ready tables for health authority review. Some of the key requirements for this undertaking are listed below:

* cell values and their visualization separate (i.e. no string based tables)
- values need to be programmatically accessible in their non-rounded state for cross-checking
* multiple values displayed within a cell
* flexible tabulation framework
* flexible formatting (cell spans, rounding, alignment, etc.)
* multiple output formats (html, ascii, latex, pdf, xml)
* flexible pagination in both horizontal and vertical directions
* distinguish between name and label in the data structure to work with `CDISC` standards
* title, footnotes, cell cell/row/column references

`rtables` currently covers virtually all of these requirements, and further advances remain under active development.

## Installation

`rtables` is available on CRAN and you can install the latest released version with:

```r
install.packages("rtables")
```

or you can install the latest development version directly from GitHub with:
`rtables.officer` can be installed with the latest development version directly from GitHub with:

```r
# install.packages("pak")
pak::pak("insightsengineering/rtables")
pak::pak("insightsengineering/rtables.officer")
```

Packaged releases (both those on CRAN and those between official CRAN releases) can be
found in the [releases list](https://github.com/insightsengineering/rtables/releases).

To understand how to use this package, please refer to the [Introduction to `rtables`](https://insightsengineering.github.io/rtables/main/articles/rtables.html) article, which provides multiple examples of code implementation.

## Cheatsheet

<a href="https://github.com/insightsengineering/rtables/blob/main/inst/cheatsheet/rtables_cheatsheet_01-24.pdf"><img src="https://raw.githubusercontent.com/insightsengineering/rtables/main/inst/cheatsheet/rtables_cheatsheet_01-24_thumbs.png" width="630" height="247"/></a>

## Usage

We first demonstrate with a demographic table-like example and then show the creation of a more complex table.

```{r, message=FALSE}
library(rtables)

lyt <- basic_table() %>%
split_cols_by("ARM") %>%
analyze(c("AGE", "BMRKR1", "BMRKR2"), function(x, ...) {
if (is.numeric(x)) {
in_rows(
"Mean (sd)" = c(mean(x), sd(x)),
"Median" = median(x),
"Min - Max" = range(x),
.formats = c("xx.xx (xx.xx)", "xx.xx", "xx.xx - xx.xx")
)
} else if (is.factor(x) || is.character(x)) {
in_rows(.list = list_wrap_x(table)(x))
} else {
stop("type not supported")
}
})

build_table(lyt, ex_adsl)
```

```{r, message=FALSE}
library(rtables)
library(dplyr)

## for simplicity grab non-sparse subset
ADSL <- ex_adsl %>% filter(RACE %in% levels(RACE)[1:3])

biomarker_ave <- function(x, ...) {
val <- if (length(x) > 0) round(mean(x), 2) else "no data"
in_rows(
"Biomarker 1 (mean)" = rcell(val)
)
}

basic_table(show_colcounts = TRUE) %>%
split_cols_by("ARM") %>%
split_cols_by("BMRKR2") %>%
split_rows_by("RACE", split_fun = trim_levels_in_group("SEX")) %>%
split_rows_by("SEX") %>%
summarize_row_groups() %>%
analyze("BMRKR1", biomarker_ave) %>%
build_table(ADSL)
```

# Acknowledgments

We would like to thank everyone who has made `rtables` a better project by providing feedback and improving examples & vignettes. The following list of contributors is alphabetical:

Maximo Carreras, Francois Collins, Saibah Chohan, Tadeusz Lewandowski, Nick Paszty, Nina Qi, Jana Stoilova, Heng Wang, Godwin Yung

## Presentations

- R in Pharma 2023
- Generating Tables, Listings, and Graphs using NEST / [cardinal](https://pharmaverse.github.io/cardinal/) [[Video](https://www.youtube.com/watch?v=YPmbLPSYFYM)]
- BBS Session on Regulatory Submissions of Clinical Trials [[Video](https://www.youtube.com/watch?v=yZS4OBuJe_Q)]
- R Medicine Virtual Conference 2023 [[Video](https://www.youtube.com/watch?v=sxFsavKI7s4)]
- Advanced rtables Training 2023 [[Part 1 Slides](https://github.com/insightsengineering/rtables/blob/main/inst/extdata/Advanced_rtables_part1.pdf)] [[Part 2 Slides](https://github.com/insightsengineering/rtables/blob/main/inst/extdata/Advances_rtables_part2.pdf)]
- R in Pharma 2022 - Creating Submission-Quality Clinical Trial Reporting Tables in R with rtables [[Slides](https://github.com/insightsengineering/rtables/blob/main/inst/extdata/Clinical_Trial_Reporting_Tables_in_R.pdf)] [[Video](https://www.youtube.com/watch?v=zBm_NZ0VtKs)]
- R Consortium 2022
- R Adoption Series - Reporting Table Creation in R [[Video](https://www.youtube.com/watch?v=1i6vOId2h4A)] [[Slides](https://github.com/insightsengineering/rtables/blob/main/inst/extdata/r_adoption_slides.pdf)]
- Tables in Clinical Trials with R [[Book](https://rconsortium.github.io/rtrs-wg/)]
- useR! 2020 - rtables Layouting and Tabulation Framework [[Video](https://www.youtube.com/watch?v=CBQzZ8ZhXLA)]
Loading
Loading