Giter VIP home page Giter VIP logo

rddi's Introduction

rddi

R-CMD-check DOI

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.

Installation

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")

Example

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()
#> <?xml version="1.0" encoding="UTF-8"?>
#> <codeBook xmlns="ddi:codebook:2_5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://www.ddialliance.org/Specification/DDI-Codebook/2.5/XMLSchema/codebook.xsd">
#>   <stdyDscr>
#>     <citation>
#>       <titlStmt>
#>         <titl>Study Title</titl>
#>       </titlStmt>
#>     </citation>
#>   </stdyDscr>
#> </codeBook>

Assert expected or required elements:

tryCatch(
  ddi_codeBook(),
  error = function(e) {
    print(e$message)
  }
)
#> No children specified when some are required: [stdyDscr]

tryCatch(
  ddi_citation(ddi_titlStmt(ddi_titl("Oops")), ddi_dataDscr()),
  error = function(e) {
    print(e$message)
  }
)
#> 'dataDscr' is not an acceptable child element for citation.
#> These are the allowed children: [titlStmt, rspStmt, prodStmt, distStmt, serStmt, verStmt, biblCit, holdings, notes]

Validate your work against the DDI Codebook 2.5 schema:

ddi_codeBook(ddi_stdyDscr(main_citation)) %>%
  validate_codebook()
#> [1] TRUE
#> attr(,"errors")
#> character(0)

rddi's People

Contributors

dswoulf avatar psanker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.