R
GoFigr's R package (gofigR) provides automatic figure capture for ggplot2, base R graphics, and more.
Compatibility
gofigR integrates with:
R Markdown (knitr)
Interactive sessions in RStudio
Shiny applications
Standalone scripts
Tested with R 4.3.2, but any reasonably recent version should work.
Installation
# From CRAN
install.packages("gofigR")
# Or from GitHub (development version)
library(devtools)
devtools::install_github("gofigr/gofigR")Configuration
Run the configuration wizard once:
This saves your credentials to ~/.gofigr.
Basic Usage
Enable GoFigr
In your setup chunk or at the start of your script:
You can optionally specify an analysis name:
Publishing Plots
Use the publish() function:
Base R Graphics
Wrap base R plotting code in publish():
You can optionally attach data:
The data argument specifies data to associate with the figure—it will appear under "Files" (as .RDS) in GoFigr.
R Markdown
In your R Markdown document:
Shiny Integration
Replace plotOutput + renderPlot with gfPlot + gfPlotServer:
Note: Pass input to gfPlotServer to capture Shiny inputs as metadata.
Common Issues
Duplicate Heatmaps with pheatmap
Some plotting functions like pheatmap::pheatmap() both draw immediately and return an object. This can cause duplicates in R Markdown.
Problem:
Solution:
Last updated