| Title: | Tools for Creating and Manipulating RO-Crates |
|---|---|
| Description: | Provides tools for creating, manipulating and reading Research Object Crates (RO-Crates), a lightweight approach to packaging research data with structured metadata. Includes utilities for metadata generation, entity management, validation and reading existing RO-Crates following the specification <https://w3id.org/ro/crate/1.2/>. |
| Authors: | Roberto Villegas-Diaz [aut, cre] (ORCID: <https://orcid.org/0000-0001-5036-8661>), Rebecca Wilson [aut] (ORCID: <https://orcid.org/0000-0003-2294-593X>), Olly Butters [aut] (ORCID: <https://orcid.org/0000-0003-0354-8461>), Stuart Wheater [aut] (ORCID: <https://orcid.org/0009-0003-2419-1964>), Research Object community [cph] |
| Maintainer: | Roberto Villegas-Diaz <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9000 |
| Built: | 2026-05-22 09:03:01 UTC |
| Source: | https://github.com/researchobject/ro-crate-r |
This helper creates an author entity and if affiliation is provided, then
creates an organisation entity for the user's affiliation.
add_author( rocrate, name, orcid = NULL, affiliation = NULL, ror = NULL, set_author = TRUE )add_author( rocrate, name, orcid = NULL, affiliation = NULL, ror = NULL, set_author = TRUE )
rocrate |
RO-Crate object, see rocrate. |
name |
Author's name. |
orcid |
Optional, ORCID identifier, for details see https://orcid.org. |
affiliation |
Optional, author's organisation. |
ror |
Optional, ROR identifier for the affiliation, for details see https://ror.org. |
set_author |
Logical, used to indicate if the current user should be set as the author of the RO-Crate. |
Updated RO-Crate object.
This helper converts an R object (typically a data.frame) into a
dataset inside the RO-Crate. The object is stored in the content
field and written to disk when calling extract_content() or
bag_rocrate(write_content = TRUE).
add_dataset( rocrate, file_id, data = NULL, name = NULL, description = NULL, encodingFormat = "text/csv" )add_dataset( rocrate, file_id, data = NULL, name = NULL, description = NULL, encodingFormat = "text/csv" )
rocrate |
RO-Crate object, see rocrate. |
file_id |
Filename for the dataset file. |
data |
R object to store (typically a |
name |
Dataset name. |
description |
Optional dataset description. |
encodingFormat |
MIME type (default |
Use this when you want to register a dataset file or directory as a formal Dataset entity inside the RO-Crate metadata.
Updated RO-Crate object.
Add entity to RO-Crate
add_entity(rocrate, entity, overwrite = FALSE, verbose = FALSE) add_entities(rocrate, entity, overwrite = FALSE, verbose = FALSE)add_entity(rocrate, entity, overwrite = FALSE, verbose = FALSE) add_entities(rocrate, entity, overwrite = FALSE, verbose = FALSE)
rocrate |
RO-Crate object, see rocrate. |
entity |
Entity object (list) that contains at least the following
components: |
overwrite |
Boolean flag to indicate if the entity (if found in the given RO-Crate) should be overwritten. |
verbose |
Boolean flag to indicate if status messages should be hidden
(default: |
Updated RO-Crate object.
basic_crate <- rocrateR::rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_v2 <- basic_crate |> rocrateR::add_entity(person_rvd) |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) ) |> rocrateR::add_entity(organisation_uol)basic_crate <- rocrateR::rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_v2 <- basic_crate |> rocrateR::add_entity(person_rvd) |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) ) |> rocrateR::add_entity(organisation_uol)
Add entity value to RO-Crate, under entity with @id = {id}, using the
pair {key}-{value} within @graph.
add_entity_value(rocrate, id, key, value, overwrite = FALSE, verbose = FALSE)add_entity_value(rocrate, id, key, value, overwrite = FALSE, verbose = FALSE)
rocrate |
RO-Crate object, see rocrate. |
id |
String with the ID of the RO-Crate entity within |
key |
String with the |
value |
String with the |
overwrite |
Boolean flag to indicate if the existing value (if any),
should be overwritten (default: |
verbose |
Boolean flag to indicate if status messages should be hidden
(default: |
Updated RO-Crate object.
basic_crate <- rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_v2 <- basic_crate |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) )basic_crate <- rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_v2 <- basic_crate |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) )
Add a notebook to an RO-Crate
add_notebook(rocrate, file_id, name = NULL, content = NULL)add_notebook(rocrate, file_id, name = NULL, content = NULL)
rocrate |
RO-Crate object, see rocrate. |
file_id |
Optional, notebook's filename. |
name |
Optional, notebook's name. |
content |
Optional, notebook's content. |
Updated RO-Crate object.
Add project metadata
add_project(rocrate, name, description = NULL)add_project(rocrate, name, description = NULL)
rocrate |
RO-Crate object, see rocrate. |
name |
Project's name. |
description |
Optional, project's description. |
Updated RO-Crate object.
Add README file to an RO-Crate
add_readme(rocrate, text, filename = "README.md")add_readme(rocrate, text, filename = "README.md")
rocrate |
RO-Crate object, see rocrate. |
text |
Character vector with README content. |
filename |
README filename. |
Updated RO-Crate object.
Add software application entity
add_software(rocrate, name, version = NULL)add_software(rocrate, name, version = NULL)
rocrate |
RO-Crate object, see rocrate. |
name |
Software name. |
version |
Version string. |
Updated RO-Crate object.
Register a workflow script (e.g. R, Python, Nextflow) as a
ComputationalWorkflow entity inside the RO-Crate.
add_workflow( rocrate, file_id, name = NULL, description = NULL, language = "R", content = NULL )add_workflow( rocrate, file_id, name = NULL, description = NULL, language = "R", content = NULL )
rocrate |
RO-Crate object, see rocrate. |
file_id |
Filename of the workflow script. |
name |
Workflow name. |
description |
Optional description. |
language |
Programming language (default |
content |
Optional script contents. |
Updated RO-Crate object.
Bag the contents of an RO-Crate using the BagIt file packaging format v1.0. For more details see the definition: doi:10.17487/RFC8493
bag_rocrate(x, ...) ## S3 method for class 'character' bag_rocrate(x, ..., output = x, force_bag = FALSE, extra_bag_info = NULL) ## S3 method for class 'rocrate' bag_rocrate( x, ..., path, output = path, overwrite = FALSE, force_bag = FALSE, extra_bag_info = NULL, write_content = TRUE, create_dir = TRUE )bag_rocrate(x, ...) ## S3 method for class 'character' bag_rocrate(x, ..., output = x, force_bag = FALSE, extra_bag_info = NULL) ## S3 method for class 'rocrate' bag_rocrate( x, ..., path, output = path, overwrite = FALSE, force_bag = FALSE, extra_bag_info = NULL, write_content = TRUE, create_dir = TRUE )
x |
A string to a path containing at the very minimum an RO-Crate
metadata descriptor file, |
... |
Additional parameters, see below. |
output |
String with path where the RO-Crate bag will be stored
(default: |
force_bag |
Boolean flag to indicate whether the force the creation of
a 'bag' even if not all the files were successfully bagged
(default: |
extra_bag_info |
Vector of strings to include in the |
path |
String with path to the root of the RO-Crate. |
overwrite |
Boolean flag to indicate if the RO-Crate metadata descriptor
file should be overwritten if already inside |
write_content |
Logical. If TRUE, write |
create_dir |
Boolean flag to indicate if the |
String with full path to the RO-Crate bag.
Other RO-Crate BagIt archive functions:
is_rocrate_bag(),
load_rocrate_bag(),
unbag_rocrate()
# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # -------- INPUT: RO-Crate -------- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: Path -------- rocrateR::bag_rocrate(tmp_dir, output = tmp_dir) # delete temp directory unlink(tmp_dir, recursive = TRUE)# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # -------- INPUT: RO-Crate -------- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: Path -------- rocrateR::bag_rocrate(tmp_dir, output = tmp_dir) # delete temp directory unlink(tmp_dir, recursive = TRUE)
Automatically create an RO-Crate from a project directory
crate_project(path = NULL)crate_project(path = NULL)
path |
String with project directory. |
RO-Crate object for the project given by path.
Create a data entity
entity(id, type, ...)entity(id, type, ...)
id |
Scalar value with |
type |
String with |
... |
Optional additional entity values/properties. |
List with an entity object.
# create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) )# create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) )
File entities content to filesWrite the content field of File entities to disk using their @id
as the filename.
extract_content(rocrate, path, overwrite = FALSE)extract_content(rocrate, path, overwrite = FALSE)
rocrate |
RO-Crate object, see rocrate. |
path |
Directory where files will be written. RO-Crate root. |
overwrite |
Logical. Overwrite existing files. |
Invisibly returns updated rocrate without contents.
Get entity(ies)
get_entity(rocrate, id = NULL, type = NULL)get_entity(rocrate, id = NULL, type = NULL)
rocrate |
RO-Crate object, see rocrate. |
id |
String with the ID of the RO-Crate entity within |
type |
String with the type of the RO-Crate entity(ies) within |
List with found entity object(s), if any, NULL otherwise.
basic_crate <- rocrateR::rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_person <- basic_crate |> rocrateR::add_entity(person_rvd) |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) ) |> rocrateR::add_entity(organisation_uol) |> rocrateR::get_entity(person_rvd) basic_crate_person[[1]]$name == person_rvd$name basic_crate_person[[1]]$`@id` == person_rvd$`@id`basic_crate <- rocrateR::rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_person <- basic_crate |> rocrateR::add_entity(person_rvd) |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) ) |> rocrateR::add_entity(organisation_uol) |> rocrateR::get_entity(person_rvd) basic_crate_person[[1]]$name == person_rvd$name basic_crate_person[[1]]$`@id` == person_rvd$`@id`
Check if object is an RO-Crate
is_rocrate(rocrate, strict = FALSE, error = TRUE)is_rocrate(rocrate, strict = FALSE, error = TRUE)
rocrate |
RO-Crate object, see rocrate. |
strict |
Boolean to indicate if stricter checks should be done (e.g., check profile specification). |
error |
Boolean to indicate if the function should throw an error, if
any errors are found (default: |
Boolean flag with RO-Crate validity.
basic_crate <- rocrateR::rocrate() # check if the new crate is valid basic_crate |> rocrateR::is_rocrate()basic_crate <- rocrateR::rocrate() # check if the new crate is valid basic_crate |> rocrateR::is_rocrate()
Check if path points to a valid RO-Crate bag
is_rocrate_bag(path, algo = NULL, bagit_version = "1.0")is_rocrate_bag(path, algo = NULL, bagit_version = "1.0")
path |
String with full path to a compressed file contain an RO-Crate bag, see bag_rocrate for details. Alternatively, a path to a directory containing an RO-Crate bag. |
algo |
String with algorithm used to generate the RO-Crate bag
(default: |
bagit_version |
String with version of BagIt used to generate the
RO-Crate bag (default: |
Returns a boolean flag to indicate if the given RO-Crate bag is valid.
Other RO-Crate BagIt archive functions:
bag_rocrate(),
load_rocrate_bag(),
unbag_rocrate()
# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # bag RO-Crate path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: RO-Crate BagIt archive -------- rocrateR::is_rocrate_bag(path_to_roc_bag) # -------- INPUT: Path -------- rocrateR::unbag_rocrate(path_to_roc_bag) |> rocrateR::is_rocrate_bag() # delete temp directory unlink(tmp_dir, recursive = TRUE)# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # bag RO-Crate path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: RO-Crate BagIt archive -------- rocrateR::is_rocrate_bag(path_to_roc_bag) # -------- INPUT: Path -------- rocrateR::unbag_rocrate(path_to_roc_bag) |> rocrateR::is_rocrate_bag() # delete temp directory unlink(tmp_dir, recursive = TRUE)
High-level loader that can read:
A ro-crate-metadata.json file
A directory containing an RO-Crate
A BagIt-wrapped RO-Crate directory
A zipped BagIt RO-Crate archive
load_rocrate(x, ...) ## S3 method for class 'rocrate' load_rocrate(x, ..., verbose = FALSE) ## S3 method for class 'character' load_rocrate( x, ..., verbose = FALSE, bagit_version = "1.0", load_content = FALSE, max_file_size = 10 * 1024^2 )load_rocrate(x, ...) ## S3 method for class 'rocrate' load_rocrate(x, ..., verbose = FALSE) ## S3 method for class 'character' load_rocrate( x, ..., verbose = FALSE, bagit_version = "1.0", load_content = FALSE, max_file_size = 10 * 1024^2 )
x |
A path (character) or an existing rocrate object. |
... |
Reserved for future extensions. |
verbose |
Logical. If |
bagit_version |
String with version of BagIt used to generate the
RO-Crate bag (default: |
load_content |
Logical. If |
max_file_size |
Maximum file size (bytes) allowed when loading content. Default 10MB. |
An RO-Crate object.
# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # -------- INPUT: RO-Crate -------- rocrateR::load_rocrate(basic_crate, verbose = TRUE) # -------- INPUT: Path -------- # save RO-Crate rocrateR::write_rocrate(basic_crate, path = tmp) # load RO-Crate ## with file name rocrateR::load_rocrate(tmp, verbose = TRUE) ## with directory rocrateR::load_rocrate(tmp_dir, verbose = TRUE) # delete temp directory unlink(tmp_dir, recursive = TRUE)# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # -------- INPUT: RO-Crate -------- rocrateR::load_rocrate(basic_crate, verbose = TRUE) # -------- INPUT: Path -------- # save RO-Crate rocrateR::write_rocrate(basic_crate, path = tmp) # load RO-Crate ## with file name rocrateR::load_rocrate(tmp, verbose = TRUE) ## with directory rocrateR::load_rocrate(tmp_dir, verbose = TRUE) # delete temp directory unlink(tmp_dir, recursive = TRUE)
Load an RO-Crate BagIt archive
load_rocrate_bag( path, algo = NULL, bagit_version = "1.0", load_content = FALSE, max_file_size = 10 * 1024^2 )load_rocrate_bag( path, algo = NULL, bagit_version = "1.0", load_content = FALSE, max_file_size = 10 * 1024^2 )
path |
String with full path to a compressed file contain an RO-Crate bag, see bag_rocrate for details. Alternatively, a path to a directory containing an RO-Crate bag. |
algo |
String with algorithm used to generate the RO-Crate bag
(default: |
bagit_version |
String with version of BagIt used to generate the
RO-Crate bag (default: |
load_content |
Logical. If |
max_file_size |
Maximum file size (bytes) allowed when loading content. Default 10MB. |
An object with the rocrate class.
Other RO-Crate BagIt archive functions:
bag_rocrate(),
is_rocrate_bag(),
unbag_rocrate()
# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # bag RO-Crate path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: RO-Crate BagIt archive -------- rocrateR::load_rocrate_bag(path_to_roc_bag) # -------- INPUT: Path -------- rocrateR::unbag_rocrate(path_to_roc_bag) |> rocrateR::load_rocrate_bag() # delete temp directory unlink(tmp_dir, recursive = TRUE)# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # bag RO-Crate path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: RO-Crate BagIt archive -------- rocrateR::load_rocrate_bag(path_to_roc_bag) # -------- INPUT: Path -------- rocrateR::unbag_rocrate(path_to_roc_bag) |> rocrateR::load_rocrate_bag() # delete temp directory unlink(tmp_dir, recursive = TRUE)
Print RO-Crate entity, S3 method for class 'entity'.
## S3 method for class 'entity' print(x, ...)## S3 method for class 'entity' print(x, ...)
x |
RO-Crate entity object, see entity. |
... |
Optional arguments, not used. |
Invisibly the input RO-Crate entity, x.
rocrateR::rocrate() |> rocrateR::get_entity("./")rocrateR::rocrate() |> rocrateR::get_entity("./")
Print RO-Crate, S3 method for class 'rocrate'. Creates a temporal JSON file, which then is displayed with the message function.
## S3 method for class 'rocrate' print(x, ..., max_lines = getOption("max_lines", 100))## S3 method for class 'rocrate' print(x, ..., max_lines = getOption("max_lines", 100))
x |
RO-Crate object, see rocrate. |
... |
Optional arguments, not used. |
max_lines |
Max number of lines to display. |
Invisibly the input RO-Crate, x.
rocrateR::rocrate()rocrateR::rocrate()
Wrapper for jsonlite::read_json. Enforces that the object read is an RO-Crate.
read_rocrate(path, simplifyVector = FALSE, ...)read_rocrate(path, simplifyVector = FALSE, ...)
path |
file on disk |
simplifyVector |
simplifies nested lists into vectors and data frames. See |
... |
Arguments passed on to
|
Invisibly the RO-Crate stored in path.
Remove entity
remove_entity(rocrate, entity, verbose = FALSE) remove_entities(rocrate, entity, verbose = TRUE)remove_entity(rocrate, entity, verbose = FALSE) remove_entities(rocrate, entity, verbose = TRUE)
rocrate |
RO-Crate object, see rocrate. |
entity |
Entity object (list) that contains at least the following
components: |
verbose |
Boolean flag to indicate if status messages should be hidden
(default: |
Updated RO-Crate object.
basic_crate <- rocrateR::rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_v2 <- basic_crate |> rocrateR::add_entity(person_rvd) |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) ) |> rocrateR::add_entity(organisation_uol) |> rocrateR::remove_entity(person_rvd)basic_crate <- rocrateR::rocrate() # create entity for an organisation organisation_uol <- rocrateR::entity( "https://ror.org/04xs57h96", type = "Organization", name = "University of Liverpool", url = "http://www.liv.ac.uk" ) # create an entity for a person person_rvd <- rocrateR::entity( "https://orcid.org/0000-0001-5036-8661", type = "Person", name = "Roberto Villegas-Diaz", affiliation = list(`@id` = organisation_uol$`@id`) ) basic_crate_v2 <- basic_crate |> rocrateR::add_entity(person_rvd) |> rocrateR::add_entity_value( id = "./", key = "author", value = list(`@id` = person_rvd$`@id`) ) |> rocrateR::add_entity(organisation_uol) |> rocrateR::remove_entity(person_rvd)
Create a new RO-Crate object. This object includes basic skeleton for the
RO-Crate metadata descriptor (ro-crate-metadata.json) file, as described
in the official documentation: https://w3id.org/ro/crate/1.2/ >
Root Data Entity.
rocrate( ..., context = "https://w3id.org/ro/crate/1.2/context", conformsTo = gsub("\\/context$", "\\1", context), datePublished = Sys.Date(), description = "", license = "http://spdx.org/licenses/CC-BY-4.0", name = "" )rocrate( ..., context = "https://w3id.org/ro/crate/1.2/context", conformsTo = gsub("\\/context$", "\\1", context), datePublished = Sys.Date(), description = "", license = "http://spdx.org/licenses/CC-BY-4.0", name = "" )
... |
Optional entities to include in the RO-Crate (e.g., author). |
context |
String with URL to the version of the RO-Crate specification to use. The context brings the defined terms into the metadata document (default: https://w3id.org/ro/crate/1.2/context). |
conformsTo |
String with URL to the version of the RO-Crate
specification which this object conforms to. Conformance declares which
RO-Crate conventions of using those terms are being followed
(default: URL formed by |
datePublished |
String (or Date object) with the date in which the RO-Crate was published (default: current date). |
description |
String with description for the root entity (default: empty string). |
license |
String with URL (permalinks are preferred, but not required) to license to be used for the overall RO-Crate. See the following resources for license choices: https://spdx.org/licenses and/or https://github.com/spdx/license-list-data/tree/main/jsonld (default: CC-BY-4.0: Creative Commons Attribution 4.0 International). |
name |
String with a name/title for the root entity (default: empty string). |
RO-Crate object, list with an additional class, rocrate.
rocrateR::rocrate()rocrateR::rocrate()
Create a new 5 Safes RO-Crate object. This object includes basic skeleton
for the RO-Crate metadata descriptor (ro-crate-metadata.json) file, as
described in the official documentation: https://w3id.org/ro/crate/1.2 >
Root Data Entity.
Additionally, it includes a profile for the 5 Safes RO-Crate:
https://w3id.org/5s-crate/0.4
rocrate_5s( ..., context = "https://w3id.org/ro/crate/1.2/context", conformsTo = gsub("\\/context$", "\\1", context), datePublished = Sys.Date(), description = "", license = "http://spdx.org/licenses/CC-BY-4.0", name = "", v5scrate = 0.4 )rocrate_5s( ..., context = "https://w3id.org/ro/crate/1.2/context", conformsTo = gsub("\\/context$", "\\1", context), datePublished = Sys.Date(), description = "", license = "http://spdx.org/licenses/CC-BY-4.0", name = "", v5scrate = 0.4 )
... |
Optional entities to include in the RO-Crate (e.g., author). |
context |
String with URL to the version of the RO-Crate specification to use. The context brings the defined terms into the metadata document (default: https://w3id.org/ro/crate/1.2/context). |
conformsTo |
String with URL to the version of the RO-Crate
specification which this object conforms to. Conformance declares which
RO-Crate conventions of using those terms are being followed
(default: URL formed by |
datePublished |
String (or Date object) with the date in which the RO-Crate was published (default: current date). |
description |
String with description for the root entity (default: empty string). |
license |
String with URL (permalinks are preferred, but not required) to license to be used for the overall RO-Crate. See the following resources for license choices: https://spdx.org/licenses and/or https://github.com/spdx/license-list-data/tree/main/jsonld (default: CC-BY-4.0: Creative Commons Attribution 4.0 International). |
name |
String with a name/title for the root entity (default: empty string). |
v5scrate |
Numeric value with the version of the 5 Safes RO-Crate profile to use. |
5 Safes RO-Crate object, list with an additional class, rocrate.
rocrateR::rocrate_5s()rocrateR::rocrate_5s()
Provides a summary of a single RO-Crate entity.
## S3 method for class 'entity' summary(object, ...)## S3 method for class 'entity' summary(object, ...)
object |
An entity object (list). |
... |
Additional arguments (unused). |
An object of class "summary.entity".
Provides a summary of the contents of an RO-Crate, including the number of entities, files and basic metadata information.
## S3 method for class 'rocrate' summary(object, ...)## S3 method for class 'rocrate' summary(object, ...)
object |
An object of class "rocrate". |
... |
Additional arguments (unused). |
An object of class "summary.rocrate".
'Unbag' (extract) RO-Crate packed with BagIt
unbag_rocrate(path, output = dirname(path), quiet = FALSE)unbag_rocrate(path, output = dirname(path), quiet = FALSE)
path |
String with path to compressed file containing an RO-Crate bag. |
output |
String with target path where the contents will be extracted
(default: |
quiet |
Boolean flag to indicate if messages should be suppressed
(default: |
String with path to root of the RO-Crate.
Other RO-Crate BagIt archive functions:
bag_rocrate(),
is_rocrate_bag(),
load_rocrate_bag()
# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # bag RO-Crate path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: Path -------- rocrateR::unbag_rocrate(path_to_roc_bag) # delete temp directory unlink(tmp_dir, recursive = TRUE)# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # bag RO-Crate path_to_roc_bag <- rocrateR::bag_rocrate(basic_crate, path = tmp_dir) # -------- INPUT: Path -------- rocrateR::unbag_rocrate(path_to_roc_bag) # delete temp directory unlink(tmp_dir, recursive = TRUE)
Performs structural, semantic and profile validation.
validate_rocrate(x, mode = c("stop", "report"), strict = FALSE)validate_rocrate(x, mode = c("stop", "report"), strict = FALSE)
x |
A path (character) or an existing rocrate object. |
mode |
Either |
strict |
Logical. Enable profile validation. |
A rocrate_validation object (in report mode).
# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # -------- INPUT: RO-Crate -------- rocrateR::validate_rocrate(basic_crate) # -------- INPUT: Path -------- # save RO-Crate rocrateR::write_rocrate(basic_crate, path = tmp) ## with file name rocrateR::validate_rocrate(tmp) ## with directory rocrateR::validate_rocrate(tmp_dir) # -------- INPUT: Invalid RO-Crate -------- structure(list(), class = "rocrate") |> rocrateR::validate_rocrate(mode = "report") # delete temp directory unlink(tmp_dir, recursive = TRUE)# -------- SETUP -------- basic_crate <- rocrateR::rocrate() # temp file tmp_dir <- file.path(tempdir(), digest::digest(basename(tempfile()))) tmp <- file.path(tmp_dir, "ro-crate-metadata.json") dir.create(tmp_dir) # -------- INPUT: RO-Crate -------- rocrateR::validate_rocrate(basic_crate) # -------- INPUT: Path -------- # save RO-Crate rocrateR::write_rocrate(basic_crate, path = tmp) ## with file name rocrateR::validate_rocrate(tmp) ## with directory rocrateR::validate_rocrate(tmp_dir) # -------- INPUT: Invalid RO-Crate -------- structure(list(), class = "rocrate") |> rocrateR::validate_rocrate(mode = "report") # delete temp directory unlink(tmp_dir, recursive = TRUE)
Wrapper for jsonlite::write_json. Enforces that the input object is an RO-Crate.
write_rocrate(x, path, ...)write_rocrate(x, path, ...)
x |
RO-Crate object, see rocrate. |
path |
file on disk |
... |
Arguments passed on to
|
Invisibly the input RO-Crate, x.