diff --git a/DESCRIPTION b/DESCRIPTION index 02e0753..85d0da6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: NRWgauges Title: Web-scraping gauge (meta-)data from various providers in NRW, Germany -Version: 0.3.2 +Version: 0.3.3 Date: 2024-12-27 Authors@R: person("Dimitri", "Falk", , "falk.dimitri@eglv.de", role = c("aut", "cre")) diff --git a/R/get_eglv_meta.R b/R/get_eglv_meta.R index 974042d..5cf8b46 100644 --- a/R/get_eglv_meta.R +++ b/R/get_eglv_meta.R @@ -32,6 +32,7 @@ get_eglv_meta <- function(x = NULL) { meta <- data.frame("id" = NA, "name" = NA, + "operator" = NA, "waterbody" = NA, "municipality" = NA, "X" = NA, @@ -63,6 +64,7 @@ get_eglv_meta <- function(x = NULL) { meta["id"] <- vals[2] meta["name"] <- vals[1] + meta["operator"] <- ifelse(as.numeric(vals[2]) > 20000, "LV", "EG") meta["waterbody"] <- vals[3] meta["municipality"] <- vals[4] meta["X"] <- vals[5] |> stringr::str_replace(pattern = ",", replacement = ".") |> as.numeric() diff --git a/tests/testthat/test-get_eglv_meta.R b/tests/testthat/test-get_eglv_meta.R index 7dda4d8..d2afebd 100644 --- a/tests/testthat/test-get_eglv_meta.R +++ b/tests/testthat/test-get_eglv_meta.R @@ -24,7 +24,7 @@ with_mock_api({ meta <- get_eglv_meta(x) - expect_equal(dim(meta), c(1, 9)) + expect_equal(dim(meta), c(1, 10)) }) test_that("Dimensions are as expected.", { @@ -33,13 +33,13 @@ with_mock_api({ meta <- get_eglv_meta(y) - expect_equal(dim(meta), c(2, 9)) + expect_equal(dim(meta), c(2, 10)) }) test_that("Column names are as expected.", { - cnames <- c("id", "name", "waterbody", "municipality", "X", "Y", "river_km", - "catchment_area", "level_zero") + cnames <- c("id", "name", "operator", "waterbody", "municipality", "X", "Y", + "river_km", "catchment_area", "level_zero") x <- get_eglv_gauges() |> dplyr::filter(id == "10103") @@ -50,8 +50,8 @@ with_mock_api({ test_that("Types are as expected.", { - dtype <- c("character", "character", "character", "character", "double", - "double", "double", "double", "double") + dtype <- c("character", "character", "character", "character", "character", + "double", "double", "double", "double", "double") x <- get_eglv_gauges() |> dplyr::filter(id == "10103")