growthcharts / bdsreader Goto Github PK
View Code? Open in Web Editor NEWRead Data from the Basisdataset Jeugdgezondheidszorg
Home Page: https://growthcharts.org/bdsreader/
License: GNU Affero General Public License v3.0
Read Data from the Basisdataset Jeugdgezondheidszorg
Home Page: https://growthcharts.org/bdsreader/
License: GNU Affero General Public License v3.0
Assume that jamesdemodata
is installed.
library(bdsreader)
# 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
#> # A tibble: 58 × 8
#> age xname yname zname zref x y z
#> <dbl> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 0 age hgt hgt_z nl_1997_hgt_female_nl 0 48 -1.52
#> 2 0.101 age hgt hgt_z nl_1997_hgt_female_nl 0.101 53.5 -0.499
#> 3 0.159 age hgt hgt_z nl_1997_hgt_female_nl 0.159 56 -0.261
#> 4 0.236 age hgt hgt_z nl_1997_hgt_female_nl 0.236 59.5 0.163
#> 5 0.485 age hgt hgt_z nl_1997_hgt_female_nl 0.485 65.5 -0.259
#> 6 0.753 age hgt hgt_z nl_1997_hgt_female_nl 0.753 71.5 0.131
#> 7 1.02 age hgt hgt_z nl_1997_hgt_female_nl 1.02 75 -0.18
#> 8 1.25 age hgt hgt_z nl_1997_hgt_female_nl 1.25 80 0.421
#> 9 1.54 age hgt hgt_z nl_1997_hgt_female_nl 1.54 84 0.527
#> 10 2.04 age hgt hgt_z nl_1997_hgt_female_nl 2.04 90 0.67
#> # … with 48 more rows
# Read file with input data according to format "2.0".
data2 <- system.file("extdata/bds_v2.0/smocc/Laura_S.json", package = "jamesdemodata")
q <- read_bds(data2, format = "2.0")
q
#> # A tibble: 49 × 8
#> age xname yname zname zref x y z
#> <dbl> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 0 age hgt hgt_z nl_1997_hgt_female_nl 0 48 -1.52
#> 2 0.101 age hgt hgt_z nl_1997_hgt_female_nl 0.101 53.5 -0.499
#> 3 0.159 age hgt hgt_z nl_1997_hgt_female_nl 0.159 56 -0.261
#> 4 0.236 age hgt hgt_z nl_1997_hgt_female_nl 0.236 59.5 0.163
#> 5 0.485 age hgt hgt_z nl_1997_hgt_female_nl 0.485 65.5 -0.259
#> 6 0.753 age hgt hgt_z nl_1997_hgt_female_nl 0.753 71.5 0.131
#> 7 1.02 age hgt hgt_z nl_1997_hgt_female_nl 1.02 75 -0.18
#> 8 1.25 age hgt hgt_z nl_1997_hgt_female_nl 1.25 80 0.421
#> 9 1.54 age hgt hgt_z nl_1997_hgt_female_nl 1.54 84 0.527
#> 10 2.04 age hgt hgt_z nl_1997_hgt_female_nl 2.04 90 0.67
#> # … with 39 more rows
table(t$yname)
#>
#> bmi dsc hdc hgt wfh wgt
#> 10 9 9 10 10 10
table(q$yname)
#>
#> bmi hdc hgt wfh wgt
#> 10 9 10 10 10
Created on 2021-10-17 by the reprex package (v2.0.1)
See problem https://github.com/growthcharts/jamesclient/issues?q=is%3Aissue+is%3Aclosed
library(bdsreader)
library(testthat)
fn2 <- system.file("extdata", "bds_v2.0", "smocc", "Laura_S.json", package = "jamesdemodata")
js2b <- jsonlite::toJSON(jsonlite::fromJSON(fn2), auto_unbox = TRUE)
test_that("Format 2.0 is read after toJSON(fromJSON(filename))", {
expect_s3_class(read_bds(js2b), "tbl_df")
})
#> ── Warning (<text>:6:3): Format 2.0 is read after toJSON(fromJSON(filename)) ───
#> provided 3 variables to replace 1 variables
#> Backtrace:
#> 1. testthat::expect_s3_class(read_bds(js2b), "tbl_df")
#> 4. bdsreader::read_bds(js2b)
#> 9. bdsreader::verify(txt, auto_format, format, schema, ...)
.../bdsreader/R/read_bds.R:111:2
#> 10. bdsreader:::parse_valid(valid)
.../bdsreader/bdsreader/R/verify.R:37:2
#> 12. base::`[<-.data.frame`(...)
.../bdsreader/bdsreader/R/parse_valid.R:65:8
#>
#> ── Error (<text>:6:3): Format 2.0 is read after toJSON(fromJSON(filename)) ─────
#> Error in `pp[pp$ElementNummer == 62L, "Waarde"]`: incorrect number of dimensions
#> Backtrace:
#> 1. testthat::expect_s3_class(read_bds(js2b), "tbl_df")
#> 9. bdsreader:::extract_dob(d, which = "01", v = v)
#> Error: Test failed
Created on 2021-11-25 by the reprex package (v2.0.1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.