context("attaining")
test.df <- data.frame(
site = c("example_1"),
class = "A",
parameter = "Chloride",
value = c(300000, 20)
) %>%
dplyr::inner_join(nysdec_wqs, by = c("class", "parameter")) %>%
mutate(direction = "<=")
test_that("wqs_attaining() returns the expected vectors.", {
expect_true(wqs_attaining("1", "+", "2", ">", "2"))
expect_false(wqs_attaining("1", "+", "2", "<", "2"))
expect_true(wqs_attaining(NA, "1", "==", "1", na.rm = TRUE))
expect_error(wqs_attaining(NA, "1", "==", "1", na.rm = FALSE),
"To remove NAs set na.rm = TRUE")
expect_equivalent(
dplyr::mutate(test.df,
test = wqs_attaining(value,
direction,
threshold)) %>%
dplyr::pull(test),
c(FALSE, TRUE)
)
expect_equivalent(
dplyr::mutate(test.df,
test = wqs_attaining(value,
direction,
threshold,
"& 1 == 1")) %>%
dplyr::pull(test),
c(FALSE, TRUE)
)
expect_equivalent(
dplyr::mutate(test.df,
test = wqs_attaining(value,
direction,
threshold,
"& 1 != 1")) %>%
dplyr::pull(test),
c(FALSE, FALSE)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.