export_as_bds: Save donordata as BDS formatted JSON

Description Usage Arguments Note Author(s) Examples

View source: R/export_as_bds.R

Description

This function selects child data from donorloader package, and save the BDS representations into one file per child.

Usage

1
2
3
4
5
6
7
8
export_as_bds(
  dnr,
  ids,
  names = NULL,
  path = NULL,
  schema = "bds_schema.json",
  indent = NULL
)

Arguments

dnr

Length-one character vector with the name(s) of the donor data

ids

Integer vector with the id number for the individuals

names

Optional. Character vector with length(ids) elements used to construct the file name. Spaces are replaced by underscores. If not specified, the function uses the ids vector to create file names.

path

Path where files should be written. By default, path is the working directory. The function creates the path if it doesn't already exist.

schema

The JSON validation schema. Either "bds_schema.json" (default) or "bds_schema_str.json" (writes numerics as strings, for backward compatibility).

indent

Integer. Number of spaces to indent when using jsonlite::prettify(). When not specified, the function writes minified json.

Note

If child birth date is unknown, then 2000-01-01 is used. Birth date of the mother is back-calculated from agem, and thus imprecise.

Author(s)

Stef van Buuren 2021

Examples

1
2
3
4
5
6
names <- c("Laura S", "Thomas S", "Anne S")
ids <- as.integer(c(34071, 34072, 34073))
## Not run: 
export_as_bds("smocc", ids, names, path = "tmp")

## End(Not run)

stefvanbuuren/donorloader documentation built on June 30, 2021, 12:15 a.m.