Skip to content

Commit

Permalink
add example for nuts_test_multiple_versions(), fix n rows dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
AAoritz committed Feb 28, 2024
1 parent 764b0f4 commit 813ad7c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions R/nuts_aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ nuts_aggregate <- function(data,
# Test for multiple versions
data <- nuts_test_multiple_versions(group_vars = group_vars, multiple_versions = multiple_versions,
data_versions = data_versions, data = data)
n_rows_dropped <- data[["n_rows_dropped"]]
message_multiple_versions <- data[["message_multiple_versions"]]
data <- data[["data"]]

Expand Down
1 change: 1 addition & 0 deletions R/nuts_convert_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ nuts_convert_version <-
# Test for multiple versions
data <- nuts_test_multiple_versions(group_vars = group_vars, multiple_versions = multiple_versions,
data_versions = data_versions, data = data)
n_rows_dropped <- data[["n_rows_dropped"]]
message_multiple_versions <- data[["message_multiple_versions"]]
data <- data[["data"]]

Expand Down
19 changes: 17 additions & 2 deletions R/nuts_test_multiple_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
#'
#' @return A tibble containing NUTS codes and a message with the results of the test.
#'
#' @examples
#' library(dplyr)
#' df <- manure %>%
#' filter(nchar(geo) == 5) %>%
#' select(geo, indic_ag, values) %>%
#' distinct(geo, .keep_all = T) %>%
#' nuts_classify(nuts_code = "geo",
#' group_vars = "indic_ag",
#' data = .)
#'
#' nuts_test_multiple_versions(group_vars = "indic_ag",
#' multiple_versions = "most_frequent",
#' data_versions = df$versions_data,
#' data = df$data)
#'
#' @export

nuts_test_multiple_versions = function(group_vars, multiple_versions, data_versions, data) {
Expand Down Expand Up @@ -56,8 +71,8 @@ nuts_test_multiple_versions = function(group_vars, multiple_versions, data_versi
c("v" = "{.blue Version is {.red unique}.}")
}

data_list <- list(data, message_multiple_versions)
names(data_list) <- c("data", "message_multiple_versions")
data_list <- list(data, n_rows_dropped, message_multiple_versions)
names(data_list) <- c("data", "n_rows_dropped", "message_multiple_versions")

return(data_list)
}
1 change: 0 additions & 1 deletion tests/testthat/test-nuts_convert_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,3 @@ test_that("Feeding multiple NUTS versions within groups. Option most frequent.",
c(1005, 5)
)
})

0 comments on commit 813ad7c

Please sign in to comment.