Learn R Programming

DDIwR (version 0.18)

makeElement: Make a DDI Codebook element

Description

Creates a standard DDI element.

Usage

makeElement(
  name,
  children = NULL,
  attributes = NULL,
  content = NULL,
  fill = FALSE,
  ...
)

Value

A standard list element of class "DDI" with reserved component names.

Arguments

name

Character, a DDI Codebook element name.

children

A list of standard DDI codebook elements.

attributes

A vector of named values.

content

Character scalar.

fill

Logical, fill the element with arbitrary values for its mandatory children and attributes

...

Other arguments, see Details.

Author

Adrian Dusa

Details

The structure of a DDI element in R follows the usual structure of an XML node, as returned by the function as_list() from package xml2, with one additional (first) component named ".extra" to accommodate any other information that is not part of the DDI element.

In the DDI Codebook, most elements and their attributes are optional, but some are mandatory. In case of attributes, some become mandatory only if the element itself is present. The mandatory elements need to be present in the final version of the Codebook, to pass the validation against the XML schema.

By activating the argument fill, this function creates DDI elements containing all mandatory (sub)elements and (their) attributes, filled with arbitrary values that can be changed later on. Some recommended elements are also filled, as expected by the CESSDA Data Catalogue profile for DDI Codebook.

By default, the Codebook is assumed to have a single language for all elements. This argument monolang can be deactivated through the ... gate, in which situation the appropriate elements will receive a default argument xmlang = "en". For other languages, that argument can also be provided through the ... gate.

One such DDI Codebook element is the stdyDscr (Study Description), with the associated mandatory children, for instance title, ID number, distributor, citation, abstract etc.

See Also

addChildren getChildren showDetails

Examples

Run this code
stdyDscr <- makeElement("stdyDscr", fill = TRUE)

# easier to extract with:
getChildren("stdyDscr/citation/titlStmt/titl", from = stdyDscr)

Run the code above in your browser using DataLab