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.
First, load a DTR schema (an ePIC datatype or an ORKG template) as an R object.
Then, create a new instance of the schema by filling in the relevant fields.
Finally, write the instance as a machine-readable JSON-LD file.
The easiest way is to install dtreg from CRAN:
install.packages("dtreg")
You can install the development version of dtreg with:
# install.packages("devtools")
library(devtools)
::install_gitlab("TIBHannover/orkg/dtreg-r", build_vignettes = TRUE) devtools
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 “data item” requires the ePIC datatype with the DOI https://doi.org/21.T11969/aff130c76e68ead3862e. For the ORKG, please use the ORKG template URL, such as https://orkg.org/template/R758316.
library(dtreg)
## load the schema with the known identifier
<- dtreg::load_datatype("https://doi.org/21.T11969/aff130c76e68ead3862e")
dt ## look at the schemata you might need to use
names(dt)
#> [1] "string" "url" "integer_in_string"
#> [4] "column" "cell" "row"
#> [7] "table" "component" "matrix_size"
#> [10] "figure" "data_item"
## check available fields for your schema
::show_fields(dt$data_item())
dtreg#> [1] "comment" "has_expression" "has_characteristic"
#> [4] "has_part" "source_table" "source_url"
#> [7] "label"
## create your own instance by filling the fields of your choice
## see the help page to know more about the fields
= "my results"
my_label <- data.frame(A = 1, B = 2, stringsAsFactors = FALSE)
my_df <- dt$url(label = "URL_1")
url_1 <- dt$url(label = "URL_2")
url_2 <- dt$data_item(
my_inst label = my_label,
has_expression = c(url_1, url_2),
source_table = my_df
)## write the instance in JSON-LD format as a string
<- dtreg::to_jsonld(my_inst)
my_json
## 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")