Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert BDS 71 (parental birth country) from integer to string #9

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading