Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vegardlysne committed Oct 16, 2024
1 parent 05c3697 commit 79bf2e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/norgeo.R
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ is_grunnkrets_00 <- function(dt){
is_kommune_99 <- function(dt){
kommune <- level <- fylke <- name <- code <- NULL

fkode <- dt[level == "fylke"][!duplicated(fylke)]
fkode <- dt[!is.na(fylke)][!duplicated(fylke)]
fkode[, kommune := paste0(fylke, "99")]
fkode[, level := "kommune"]
fkode[, name := "Uoppgitt"]
Expand Down
8 changes: 6 additions & 2 deletions tests/testthat/test-norgeo-recode.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ test_that("Grunnkrets ends with 00", {
level = c("grunnkrets", "grunnkrets", "grunnkrets", "grunnkrets"),
grunnkrets = c("03010100", "03010101", "54449900", "54449999"),
kommune = c(NA, "0301", NA, "5444"), fylke = c(NA, "03", NA, "54"),
bydel = c(NA, "030116", NA, NA)),
bydel = c(NA, "030116", NA, NA),
levekaar = rep(NA_character_, 4),
okonomisk = rep(NA_character_, 4)),
row.names = c(NA, -4L),
class = c("data.table", "data.frame"), sorted = "code")

Expand All @@ -38,7 +40,9 @@ test_that("Grunnkrets ends with 00", {
grunnkrets = c("03010100", "03010101", "54449900", "54449999"),
kommune = c("0301", "0301", "5444", "5444"),
fylke = c("03", "03", "54", "54"),
bydel = c("030116", "030116", NA, NA)),
bydel = c("030116", "030116", NA, NA),
levekaar = rep(NA_character_,4),
okonomisk = rep(NA_character_,4)),
row.names = c(NA, -4L),
class = c("data.table", "data.frame"), sorted = "code")

Expand Down

0 comments on commit 79bf2e2

Please sign in to comment.