Converts data in donordata format to a JSON file per child.

export_as_bds(data, ids, path = NULL, names = NULL, indent = NULL, ...)

Arguments

data

Dataset in donordata format (having child and time elements)

ids

Integer vector with the id number for the individuals

path

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

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.

indent

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

...

Forwarded to write_bds()

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

Stef van Buuren 2021

Examples

names <- c("Laura S", "Thomas S")
ids <- as.integer(c(34071, 34072))
if (FALSE) { # \dontrun{
export_as_bds(minidata, ids = ids, names = names, indent = 2)
} # }