Skip to content

Commit

Permalink
Merge pull request #9 from growthcharts/bds71
Browse files Browse the repository at this point in the history
Convert BDS 71 (parental birth country) from integer to string
  • Loading branch information
stefvanbuuren committed Mar 21, 2024
2 parents 885e25f + 38cff61 commit 1773455
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
12 changes: 5 additions & 7 deletions R/convert_checked_list_3.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,15 @@ convert_checked_list_3 <- function(bds, ds) {
first()
}

if (all(hasName(bds, c("number", "nest", "code")))) {
if (all(hasName(bds, c("character", "nest", "code")))) {
psn[["blbf"]] <-
filter(bds, bds == 71L & .data$nest == 62L & .data$code == "01") %>%
pull("number") %>%
first() %>%
as.integer()
pull("character") %>%
first()
psn[["blbm"]] <-
filter(bds, bds == 71L & .data$nest == 62L & .data$code == "02") %>%
pull("number") %>%
first() %>%
as.integer()
pull("character") %>%
first()
}

if (all(hasName(bds, c("category", "nest", "code")))) {
Expand Down
4 changes: 2 additions & 2 deletions R/convert_raw_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ set_type <- function(bds) {
948, 949, 950, 953, 954, 972, 980, 982, 984,
998, 1001, 1278)
date <- c(20, 63)
number <- c(71, 82, 110, 235, 238, 240, 245, 252, 471)
character <- c(16)
number <- c(82, 110, 235, 238, 240, 245, 252, 471)
character <- c(16, 71)

type <- rep(NA_character_, length(bds))
type[bds %in% category] <- "category"
Expand Down
2 changes: 1 addition & 1 deletion data-raw/R/bds_lexicon.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ create_bds_lexicon <- function() {
"one of: 01, 02, 03, 04, 05, 06, 07, 08, 98",
"yyyymmdd",
"one of: 01, 02, 03, 04, 05, 06, 07, 08, 98, 00",
"4-digit code",
"string with 4-digits",
"in days",
"one of: 1, 2, 99",
"in grammes",
Expand Down
4 changes: 2 additions & 2 deletions inst/examples/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
},
{
"bdsNumber": 71,
"value": 6030
"value": "6030"
}
]
},
Expand All @@ -110,7 +110,7 @@
},
{
"bdsNumber": 71,
"value": 6030
"value": "6030"
},
{
"bdsNumber": 66,
Expand Down
14 changes: 1 addition & 13 deletions inst/schemas/bds_v3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
{
"properties": {
"bdsNumber": {
"const": 16
"enum": [16, 71]
},
"value": {
"type": "string",
Expand Down Expand Up @@ -137,18 +137,6 @@
"value": {"enum": ["01", "02", "03", "04", "05", "06", "07", "08", "09", "98", "00"]}
}
},
{
"properties": {
"bdsNumber": {
"const": 71
},
"value": {
"type": "number",
"minimum": 1000,
"maximum": 9999
}
}
},
{
"properties": {
"bdsNumber": {
Expand Down

0 comments on commit 1773455

Please sign in to comment.