library (surveyreader)
library(testthat)
context("Scaling factors")
test_that("correct numeric conversion takes place", {
expect_equal(
sum ( scale_factor (column = as.character (c("3 - city",
"2 - town", NA, "missing", "1 - village")),
digits = 1,
na_id = "missing",
is_integer = FALSE ), na.rm = TRUE),
6
)
expect_equal(
sum(is.na(scale_factor (column = as.character (c("3 - city",
"2 - town", NA, "missing", "1 - village")),
digits = 1,
na_id = "missing",
is_integer = FALSE ))),
2
)
})
test_that("correct warnings are made", {
expect_warning(scale_factor (column = as.character (c("3 - city",
"2 - town", NA, "missing", "1 - village")),
digits = 1,
na_id = "NA",
is_integer = FALSE )
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.