Learn R Programming

⚠️There's a newer version (0.1.1) of this package.Take me there.

reportRmd

The goal of reportRmd is to automate the reporting of clinical data in Rmarkdown environments. Functions include table one-style summary statistics, compilation of multiple univariate models, tidy output of multivariable models and side by side comparisons of univariate and multivariable models. Plotting functions include customisable survival curves, forest plots, and automated bivariate plots.

Installation

Installing from CRAN:

install.packages('reportRmd')

You can install the development version of reportRmd from GitHub with:

# install.packages("devtools")
devtools::install_github("biostatsPMH/reportRmd", ref="development")

New Features

  • Survival curves have been improved and now return ggplots
  • Variable labels will now be automatically output in tables

Documentation

Online Documentation

Examples

Summary statistics by Sex

library(reportRmd)
data("pembrolizumab")
rm_covsum(data=pembrolizumab, maincov = 'sex',
covs=c('age','pdl1','change_ctdna_group'),
show.tests=TRUE)

Using Variable Labels

var_names <- data.frame(var=c("age","pdl1","change_ctdna_group"),
                          label=c('Age at study entry',
                                  'PD L1 percent',
                                  'ctDNA change from baseline to cycle 3'))

pembrolizumab <- set_labels(pembrolizumab,var_names)

rm_covsum(data=pembrolizumab, maincov = 'sex',
covs=c('age','pdl1','change_ctdna_group'))

Multiple Univariate Regression Analyses

rm_uvsum(data=pembrolizumab, response='orr',
covs=c('age','pdl1','change_ctdna_group'))
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...

Tidy multivariable analysis

glm_fit <- glm(orr~change_ctdna_group+pdl1+cohort,
               family='binomial',
               data = pembrolizumab)
rm_mvsum(glm_fit,showN=T)

Combining univariate and multivariable models

uvsumTable <- rm_uvsum(data=pembrolizumab, response='orr',
covs=c('age','sex','pdl1','change_ctdna_group'),tableOnly = TRUE)
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...
#> Waiting for profiling to be done...

glm_fit <- glm(orr~change_ctdna_group+pdl1,
               family='binomial',
               data = pembrolizumab)
mvsumTable <- rm_mvsum(glm_fit,tableOnly = TRUE)

rm_uv_mv(uvsumTable,mvsumTable)

Simple survival summary table

Shows events, median survival, survival rates at different times and the log rank test. Does not allow for covariates or strata, just simple tests between groups

 rm_survsum(data=pembrolizumab,time='os_time',status='os_status',
 group="cohort",survtimes=c(12,24),
# group="cohort",survtimes=seq(12,36,12),
# survtimesLbls=seq(1,3,1),
 survtimesLbls=c(1,2),
 survtimeunit='yr')

Summarise Cumulative incidence

library(survival)
data(pbc)
rm_cifsum(data=pbc,time='time',status='status',group=c('trt','sex'),
eventtimes=c(1825,3650),eventtimeunit='day')
#> 106 observations with missing data were removed.

Plotting survival curves

ggkmcif2(response = c('os_time','os_status'),
cov='cohort',
data=pembrolizumab)

Plotting odds ratios

require(ggplot2)
#> Loading required package: ggplot2
forestplot2(glm_fit)
#> Warning: `forestplot2()` was deprecated in reportRmd 0.1.0.
#> ℹ Please use `forestplotUV()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: Vectorized input to `element_text()` is not officially supported.
#> ℹ Results may be unexpected or may change in future versions of ggplot2.

Plotting bivariate relationships

These plots are designed for quick inspection of many variables, not for publication.

require(ggplot2)
plotuv(data=pembrolizumab, response='orr',
covs=c('age','cohort','pdl1','change_ctdna_group'))
#> Boxplots not shown for categories with fewer than 20 observations.
#> Boxplots not shown for categories with fewer than 20 observations.

Copy Link

Version

Install

install.packages('reportRmd')

Monthly Downloads

271

Version

0.1.0

License

MIT + file LICENSE

Maintainer

Lisa Avery

Last Published

November 16th, 2023

Functions in reportRmd (0.1.0)

pembrolizumab

Survival data Survival status and ctDNA levels for patients receiving pembrolizumab
hbld

Bold strings in HTML
pvalue

Formats p-values
rm_cifsum

Summarize cumulative incidence by group
rm_uv_mv

Combine univariate and multivariable regression tables
rm_survtime

Display survival rates and events for specified times
plotuv

Plot multiple bivariate relationships in a single plot
lbld

Bold strings in LaTeX
geoR_boxcoxfit

Parameter Estimation for the Box-Cox Transformation
outTable

Print tables to PDF/Latex HTML or Word
rm_mvsum

Format a regression model nicely for 'Rmarkdown'
rm_covsum

Outputs a descriptive covariate table
niceNum

Round retaining digits
nicename

Lean strings for printing
rm_uvsum

Output several univariate models nicely in a single table
mvsum

Get multivariate summary dataframe
set_var_labels

Set variable labels
nestTable

Combine two table columns into a single column with levels of one nested within levels of the other.
lpvalue

Formats p-values for LaTeX
rm_survdiff

Display event counts, expected event counts and logrank test of differences
rm_survsum

Summarise survival data by group
uvsum

Get univariate summary dataframe
rmds

Replace dollar signs with html for proper HTML output
testData

Funky ctDNA data There is a weird factor with all one level, the cohort variable contains a cohort level (and Cohort A) and for one cohort all the size changes are missing
set_labels

Set variable labels
pstprn

Paste with parentheses
sanitizestr

Sanitizes strings to not break LaTeX
psthr

Round and paste with parentheses
boxcoxfitRx

fit box cox transformed linear model
clear_labels

Clear variable labels from a data frame
excelColLetters

Retrieve spreadsheet column letter-names from columns indices
extract_labels

Extract variable labels from labelled data frame
excelCol

Retrieve columns number from spreadsheet columns specified as unquoted letters
ggkmcif

Plot KM and CIF curves with ggplot
ggkmcif2Parameters

Additional parameters passed to ggkmcif2
ggkmcif2

Plot KM and CIF curves with ggplot
cap

Capitalize a string
forestplotUV

Create an univariable forest plot using ggplot2
forestplot2

Create a forest plot using ggplot2
ctDNA

Tumour size change over time Longitudinal changes in tumour size since baseline for patients by changes in ctDNA status (clearance, decrease or increase) since baseline.
forestplotUVMV

Combine an univariable and multivariable forest plot using ggplot2
formatp

Specific p-value formatting
forestplotMV

Create a multivariable forest plot using ggplot2
addspace

Add spaces to strings in LaTeX
crrRx

fit crr model
covsum

Get covariate summary dataframe
ggkmcif_paste

Plot KM and CIF curves with ggplot