Making a PRISMA flow diagram in R means generating the study selection figure programmatically from a data file, so the diagram regenerates automatically whenever your numbers change. The official PRISMA2020 R package, written by the authors of the PRISMA 2020 statement, reads a structured template of your counts and produces an interactive or static flow diagram that you can export as SVG, PNG, PDF, or HTML. If you would rather skip the code entirely, our free PRISMA 2020 flow diagram generator produces the same publication-ready figure in the browser, but the R route is the gold standard for fully reproducible reviews.
The appeal of R is reproducibility. When a reviewer asks you to add a database or correct an exclusion count six months after submission, a coded diagram rebuilds in seconds with a perfect audit trail, rather than being redrawn by hand.
When R Is Worth It, and When a Web Tool Is Faster
Reach for R when reproducibility is the priority: a registered report, a Cochrane review, or any project where the figure must regenerate from raw data on demand. R also wins when you already manage screening counts in a script and want the diagram to flow from the same pipeline.
A browser tool is faster when you simply need one correct figure for a thesis or a single submission and do not want to install anything. Our comparison of the best PRISMA flow diagram tools weighs these trade-offs across the main options. Many researchers use both: R for the reproducible pipeline and a web tool for a quick draft while screening is still in progress.
Installing the PRISMA2020 Package
The package is on CRAN, so installation is a single line. Install it once, then load it in each session:
install.packages("PRISMA2020")
library(PRISMA2020)
The package bundles a CSV template that defines every box in the diagram. Loading the bundled example is the quickest way to see the expected structure before you enter your own data.
Preparing Your Data Template
The diagram is driven by a CSV with one row per box and a numeric value for each. You can read the template, edit the values, and pass it to the data-preparation function:
# Read the bundled CSV template
csv <- read.csv(
system.file("extdata", "PRISMA.csv", package = "PRISMA2020")
)
# Convert the template into the structure the diagram needs
data <- PRISMA_data(csv)
Each row in the template maps to a familiar PRISMA box: records identified from databases and registers, duplicates removed, records screened and excluded, reports sought and not retrieved, reports assessed and excluded with reasons, and studies included. If those units are unfamiliar, our explainer on what goes in each PRISMA box defines records, reports, and studies precisely.
Generating the Flow Diagram
With the data prepared, one function call renders the figure:
plot <- PRISMA_flowdiagram(
data,
interactive = TRUE,
previous = FALSE,
other = TRUE
)
plot
The arguments control the layout directly:
- previous toggles the boxes for a previous version of the review, used for updates.
- other toggles the "other sources" column for citation searching, websites, and registers.
These two switches correspond exactly to the four official layouts, which our guide to the PRISMA 2020 flow diagram templates describes. Setting them correctly is what makes the diagram match your search methodology.
Exporting From R to SVG, PNG, PDF, or HTML
One advantage of R is clean vector output. The package provides a save function that writes several formats:
PRISMA_save(
plotobj = plot,
filename = "prisma_flow.svg",
filetype = "SVG"
)
Switch the filetype argument to write "PNG", "PDF", or "HTML". For journal submission, the SVG or PDF output gives you a true vector figure that scales without blur, which our guide on PRISMA diagram export formats explains is exactly what some publishers require. The interactive HTML version is useful for sharing a clickable diagram with co-authors during drafting.
A ggplot2 Alternative
If you prefer to build the figure inside the tidyverse, the community packages PRISMAstatement and metagear offer flow-diagram functions with a more ggplot-like feel. They give finer control over styling but require you to specify box contents manually, so they trade convenience for flexibility. For most users the official PRISMA2020 package is the better starting point because it encodes the 2020 structure and four templates out of the box.
Common Errors and How to Fix Them
- A box shows zero or NA: check that the corresponding row in your CSV has a numeric value and no stray text.
- The "other sources" column is missing: set
other = TRUEin the diagram call and ensure those rows are populated. - Export looks pixelated: write to SVG or PDF rather than PNG, or increase the PNG dimensions in the save call.
- Numbers do not reconcile: the package draws whatever you provide, so a chain that does not subtract cleanly points to a data error, not a code error.
Once your pipeline runs end to end, updating the review is trivial: edit the CSV, rerun the script, and the diagram regenerates. For the manual data-entry equivalent, our step-by-step guide to creating a PRISMA flow diagram covers the same fields in the browser.
Frequently Asked Questions
Is the PRISMA2020 R package free?
Yes. It is open source, published on CRAN, and maintained by authors associated with the PRISMA 2020 statement. You can install and use it at no cost.
Can I export a vector PRISMA diagram from R?
Yes. The package's save function writes SVG and PDF, both of which are vector formats that stay sharp at any size. This is helpful when a journal requests vector line art rather than a raster image.
Do I need to know R to make a PRISMA flow diagram?
No. R is one option, valued for reproducibility, but a browser generator produces the same publication-ready figure without any code. Choose R when you need the diagram to regenerate automatically from data.
What is the difference between the PRISMA2020 package and PRISMAstatement?
PRISMA2020 is the official package encoding the 2020 structure and its four templates, driven by a CSV. PRISMAstatement and metagear are community packages with a more manual, ggplot-style approach that trades built-in structure for styling control.
How do I make a diagram for an updated review in R?
Set previous = TRUE in the PRISMA_flowdiagram call and populate the previous-version rows in your data template. This adds the boxes that combine prior and newly identified studies.