Easily Create Production-Ready Rich Text Format (RTF) Tables and Figures

Create production-ready Rich Text Format (RTF) tables and figures with flexible format.


r2rtf

CRANstatus Codecov testcoverage CRANDownloads R-CMD-check status

Overview

r2rtf is an R package to create production-ready tables and figures in RTF format. The package is designed with these principles:

  • Provide simple “verb” functions that correspond to each component of a table, to help you translate data frame(s) to a table in RTF file.
  • Functions are chainable with pipes (%>%).
  • Only focus on table format.
    • Data manipulation and analysis should be handled by other R packages, for example, tidyverse.
  • Minimize package dependency.

The R for clinical study reports and submission book provides tutorials by using real world examples.

Installation

You can install the package via CRAN:

install.packages("r2rtf")

Or, install from GitHub:

remotes::install_github("Merck/r2rtf")

Highlighted features

The R package r2rtf provides flexibility to enable features below:

  • Create highly customized RTF tables and figures ready for production.
  • Simple to use parameters and data structure.
    • Customized column header: split by "|".
    • Three required parameters for the output tables (data, filename, column relative width).
    • Flexible and detail control of table structure.
  • Format control in cell, row, column and table level for:
    • Border Type: single, double, dash, dot, etc.
    • Alignment: left, right, center, decimal.
    • Column width.
    • Text appearance: bold, italics, strikethrough, underline and any combinations.
    • Font size.
    • Text and border color (657 different colors named in color() function).
    • Special characters: any character in UTF-8 encoding (e.g., Greek, Symbol, Chinese, Japanese, Korean).
  • Append several tables into one file.
  • Pagination.
  • Built-in raw data for validation.

Simple example

library(dplyr)
library(r2rtf)

head(iris) %>%
  rtf_body() %>% # Step 1 Add attributes
  rtf_encode() %>% # Step 2 Convert attributes to RTF encode
  write_rtf(file = "ex-tbl.rtf") # Step 3 Write to a .rtf file

Click here to see the output

Example efficacy table

Click here to see the output

Example safety table

Click here to see the output

Citation

If you use this software, please cite it as below.

Wang, S., Ye, S., Anderson, K., & Zhang, Y. (2020). r2rtf—an R Package to Produce Rich Text Format (RTF) Tables and Figures. PharmaSUG. https://pharmasug.org/proceedings/2020/DV/PharmaSUG-2020-DV-198.pdf

A BibTeX entry for LaTeX users is

@inproceedings{wang2020r2rtf,
  title     = {{r2rtf}---an {R} Package to Produce {Rich Text Format} ({RTF}) Tables and Figures},
  author    = {Wang, Siruo and Ye, Simiao and Anderson, Keaven M and Zhang, Yilong},
  booktitle = {PharmaSUG},
  year      = {2020},
  url       = {https://pharmasug.org/proceedings/2020/DV/PharmaSUG-2020-DV-198.pdf}
}

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("r2rtf")

1.3.1 by Ruchitbhai Patel, 4 months ago


https://merck.github.io/r2rtf/, https://github.com/Merck/r2rtf


Report a bug at https://github.com/Merck/r2rtf/issues


Browse source code at https://github.com/cran/r2rtf


Authors: Yilong Zhang [aut] , Siruo Wang [aut] , Simiao Ye [aut] , Fansen Kong [aut] , Brian Lang [aut] , Benjamin Wang [aut] , Nan Xiao [ctb] , Madhusudhan Ginnaram [ctb] , Ruchitbhai Patel [aut, cre] , Huei-Ling Chen [ctb] , Peikun Wu [ctb] , Uday Preetham Palukuru [ctb] , Daniel Woodie [ctb] , Sarad Nepal [ctb] , Jane Liao [ctb] , Jeff Cheng [ctb] , Yirong Cao [ctb] , Amin Shirazi [ctb] , Yihui Xie [ctb] , Günter Milde [ctb] (Original author of the unimathsymbols.txt file) , Merck Sharp & Dohme Corp [cph]


Documentation:   PDF Manual  


GPL-3 license


Imports grDevices, tools

Suggests covr, dplyr, emmeans, ggplot2, knitr, magrittr, officer, rmarkdown, stringi, testthat, tidyr, xml2


Imported by gsDesign, gsDesign2, metalite.ae, metalite.sl, metalite.table1, repfun.

Suggested by forestly, formatters, metalite, rtables.


See at CRAN