rocrateR: Tools for Creating and Manipulating RO-Crates logo

CRAN status R-CMD-check Codecov test coverage Lifecycle: experimental

{rocrateR} provides a native R interface for creating, manipulating, validating and packaging RO-Crates. RO-Crate is a lightweight approach to packaging research data with structured metadata using JSON-LD.

Installation

You can install the released version of {rocrateR} from CRAN with:

install.packages("rocrateR")

And the development version from GitHub with:

# install.packages("pak")
pak::pak("ResearchObject/ro-crate-r@dev")

Quick Start

# create a crate
crate <- rocrateR::rocrate()

crate <- crate |>
  # add a dataset entity
  rocrateR::add_dataset("iris.csv", iris) |>
  # add workflow entity
  rocrateR::add_workflow(
    file_id = "analysis.R",
    name = "Data analysis pipeline",
    content = c(
      "data <- read.csv('iris.csv')",
      "summary(data)"
    )
  ) |>
  # add software entity
  rocrateR::add_software("R", version = R.version.string)

# write to disk
path_to_rocrate_bag <- rocrateR::bag_rocrate(crate, path = "./my_roc")

path_to_rocrate_bag_contents <- path_to_rocrate_bag |>
    rocrateR::unbag_rocrate(output = "ROC")
#> ROC
#> ├── bag-info.txt
#> ├── bagit.txt
#> ├── data
#> │   ├── analysis.R
#> │   ├── iris.csv
#> │   └── ro-crate-metadata.json
#> ├── manifest-sha512.txt
#> └── tagmanifest-sha512.txt

What You Can Do

Typical Workflow

roc_bag_path <- rocrateR::crate_project() |>
  rocrateR::add_author("Alice Smith") |>
  rocrateR::add_dataset("data/raw.csv") |>
  rocrateR::add_software("analysis.R") |>
  rocrateR::bag_rocrate(path = ".")

Validation

rocrateR::validate_rocrate(roc_bag_path)

Learn More

For further details, see the following vignette:

vignette("getting-started-with-rocrateR")

Why rocrateR?