MyNixOS website logo
Description

R Interface to DDI Codebook 2.5.

A direct interface to the underlying XML representation of DDI Codebook 2.5 with flexible API creation.

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

Version

0.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows