| read_bds | R Documentation |
This function takes data from a json source, optionally validates the
contents against a JSON validation schema, perform checks, calculates
the D-score, calculates Z-scores and stores the data in an list with
elements psn and xyz.
read_bds(
txt = NULL,
auto_format = TRUE,
format = "1.0",
schema = NULL,
validate = FALSE,
append_ddi = FALSE,
intermediate = FALSE,
verbose = FALSE,
...
)
txt |
A JSON string, URL or file |
auto_format |
Logical. Should the format be read from the data? Default
is |
format |
String. JSON data schema version number. There are currently
three schemas supported: |
schema |
A file name (optionally including the path) with the JSON
validation schema.
The |
validate |
Logical. Should the JSON-input be validated against the
JSON-schema? The default ( |
append_ddi |
Should the DDI responses be appended? (only used for JSON schema V1.0 and V2.0) |
intermediate |
Logical. If
|
verbose |
Show verbose output for |
... |
Ignored |
If txt is unspecified or NULL, then the return component will "xyz"
have zero rows.
The format and schema arguments specify the format of the JSON input
data argument txt. The default format = "1.0" expects that the JSON
input data conform to the schema specified in
system.file("schemas/bds_v1.0.json", package = "bdsreader"). This is only
supported for legacy. We recommend format "3.0", which expects data
coded according to
system.file("schemas/bds_v3.0.json", package = "bdsreader").
The format can be specified in the JSON data file with an entry
named Format. For auto_format == TRUE, the data specification overrides
any format and schema arguments to the read_bds() function.
Schema bds_v3.0.json requires the Format field, so the correct format
is automatically set by the data.
Legacy note: If you erroneously read a JSON file of format "1.0" using
format "2.0" you may see an error:
Error ...: incorrect number of dimensions.
In that make sure that you are reading with the format = "1.0" argument.
Reversely, if you erroneously read a JSON file of format "2.0" using format
"1.0" you may see messages .ClientGegevens should be object and
Missing 'ClientGegevens$Groepen'. In that case, specify format = "2.0".
A list with elements named "psn" and "xyz".
jsonlite::fromJSON(), centile::y2z()
fn <- system.file("json", "examples", "maria1.json", package = "jamesdemodata")
m <- read_bds(fn)
m
data2 <- system.file("extdata", "bds_v3.0", "smocc", "Laura_S.json",
package = "jamesdemodata")
q <- read_bds(data2)
q
# Equivalent, but specifying the built-in schema file bds_v3.0.json
schema3 <- system.file("schemas", "bds_v3.0.json", package = "bdsreader")
r <- read_bds(data2, schema = schema3)
identical(q, r)
# Automatic detection of format 3.0
# s <- read_bds(data2)
# identical(q, s)
# Reading data with older format (bds_v1.0)
data1 <- system.file("extdata", "bds_v1.0", "smocc", "Laura_S.json",
package = "jamesdemodata")
t <- read_bds(data1)
t
# same, but using a built-in schema file
schema1 <- system.file("schemas", "bds_v1.0.json", package = "bdsreader")
u <- read_bds(data1, schema = schema1)
identical(t, u)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.