dtreg

CRAN status Coverage Status

The goal of dtreg is to help users interact with various data type registries (DTRs) and create machine-readable data. Currently, we support the ePIC and ORKG DTRs.

Installation

The easiest way is to install dtreg from CRAN:

install.packages("dtreg")

Development version

You can install the development version of dtreg with:

# install.packages("devtools")
library(devtools)
devtools::install_gitlab("TIBHannover/orkg/dtreg-r", build_vignettes = TRUE)

Example

This brief example shows you how to work with a DTR schema. You need to know the schema identifier (see the help page ). For instance, the schema “inferential test output” requires the ePIC datatype with the DOI https://doi.org/21.T11969/74bc7748b8cd520908bc. For the ORKG, please use the ORKG template URL, such as https://incubating.orkg.org/template/R855534.

library(dtreg)
## load the schema with the known identifier
dt <- dtreg::load_datatype("https://doi.org/21.T11969/74bc7748b8cd520908bc")
## look at the schemata you might need to use
names(dt)
#> [1] "string"                  "url"                    
#> [3] "integer_in_string"       "column"                 
#> [5] "cell"                    "row"                    
#> [7] "table"                   "inferential_test_output"
## check available fields for your schema
dtreg::show_fields(dt$inferential_test_output())
#> [1] "has_format"      "comment"         "has_description" "label"
## create your own instance by filling the fields of your choice
## see the help page to know more about the fields
my_label = "my results"
my_df <- data.frame(A = 1, B = 2, stringsAsFactors = FALSE)
url_1 <- dt$url(label = "URL_1")
url_2 <- dt$url(label = "URL_2")
my_inst <- dt$inferential_test_output(label = my_label,
                                      has_description = c(url_1, url_2),
                                      has_format = my_df)
## write the instance in JSON-LD format as a string
my_json <- dtreg::to_jsonld(my_inst)

## the result can be saved as a JSON file
## write(my_json, "my_file.json")

For more information, please see the help page and dtreg vignette. To access the vignette, you can run:

vignette("dtreg", package="dtreg")