knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This developer-focused package provides R representations of DDI Codebook 2.5 elements to safely construct fully-validated XML while still being flexible. There are 351 elements in the codebook schema, and while it is the intention of the package to ultimately cover most (if not all) of these, rddi also provides safe node creation tools to quickly create missing elements of the schema.
Install the latest stable version from CRAN:
install.packages("rddi")
Install the development from this repository with:
# install.packages("devtools") devtools::install_github("nyuglobalties/rddi")
Building components is quick and simple:
library(rddi) library(magrittr) main_citation <- ddi_citation(ddi_titlStmt(ddi_titl("Study Title"))) ddi_codeBook(ddi_stdyDscr(main_citation)) %>% as_xml_string() %>% cat()
Assert expected or required elements:
tryCatch( ddi_codeBook(), error = function(e) { print(e$message) } ) tryCatch( ddi_citation(ddi_titlStmt(ddi_titl("Oops")), ddi_dataDscr()), error = function(e) { print(e$message) } )
Validate your work against the DDI Codebook 2.5 schema:
ddi_codeBook(ddi_stdyDscr(main_citation)) %>% validate_codebook()
Convert to XML
xml <- as_xml(ddi_codeBook(ddi_stdyDscr(main_citation)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.