A Framework for Planning and Executing Analyses

A comprehensive framework for planning and executing analyses in R. It provides a structured approach to running the same function multiple times with different arguments, executing multiple functions on the same datasets, and creating systematic analyses across multiple strata or variables. The framework is particularly useful for applying the same analysis across multiple strata (e.g., locations, age groups), running statistical methods on multiple variables (e.g., exposures, outcomes), generating multiple tables or graphs for reports, and creating systematic surveillance analyses. Key features include efficient data management, structured analysis planning, flexible execution options, built-in debugging tools, and hash-based caching.


plnr

CRAN status CRAN downloads

Overview

plnr is a framework for planning and executing analyses in R. Use it when you need to do one of these:

  • Run the same function multiple times with different arguments
  • Run multiple different functions on the same datasets
  • Create systematic analyses across multiple strata or variables

Key Features

  • Efficient Data Management: Load the data once and reuse it across multiple analyses
  • Structured Analysis Planning: Organize analyses into clear, maintainable plans
  • Flexible Execution: Support for both single-function and multi-function analysis plans
  • Built-in Debugging: Tools for development and testing
  • Parallel Processing: Optional parallel execution of analyses
  • Hash-based Caching: Track data changes and optimize execution

Common Use Cases

  • Apply the same analysis across multiple strata, such as locations or age groups
  • Run statistical methods on multiple variables, such as exposures or outcomes
  • Create multiple tables or graphs for reports
  • Create systematic surveillance analyses

Installation from CRAN

install.packages("plnr")

Getting Started

  1. Read the introduction vignette.
  2. Read the adding analyses guide.
  3. Run help(package="plnr") for the function documentation.

Quick Example

library(plnr)
library(ggplot2)
library(data.table)

# Create a new plan
p <- Plan$new()

# Add data
p$add_data(
  name = "deaths",
  direct = data.table(deaths=1:4, year=2001:2004)
)

# Add analyses for different years
p$add_argset(name = "fig_1_2002", year_max = 2002)
p$add_argset(name = "fig_1_2003", year_max = 2003)

# Define analysis function
fn_fig_1 <- function(data, argset) {
  plot_data <- data$deaths[year <= argset$year_max]
  ggplot(plot_data, aes(x=year, y=deaths)) +
    geom_line() +
    geom_point(size=3) +
    labs(title = glue::glue("Deaths from 2001 until {argset$year_max}"))
}

# Apply function to all argsets
p$apply_action_fn_to_all_argsets(fn_name = "fn_fig_1")

# Run analyses
p$run_one("fig_1_2002")

Contributing

Contributions are welcome. Submit a Pull Request.

License

The MIT License covers this package. Read the LICENSE file for the full text.

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("plnr")

2026.9.23 by Richard Aubrey White, 24 days ago


https://www.rwhite.no/plnr/, https://github.com/raubreywhite/plnr


Report a bug at https://github.com/raubreywhite/plnr/issues


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


Authors: Richard Aubrey White [aut, cre, cph] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports data.table, digest, fs, foreach, glue, pbmcapply, purrr, R6, stats, tidyr, usethis, utils, uuid

Suggests testthat, knitr, rmarkdown, progressr, ggplot2, readxl


Suggested by csalert.


See at CRAN