library (surveyreader)
library(testthat)
context("Converting logical character values to numeric values.")
test_that("correct numeric conversion takes place", {
expect_equal(
sum ( chr_logical(column = as.character (c("1 - yes", "1", "0 - no",
"missing", NA)),
false_id = "0 - no", true_id = "1 - yes",
na_labels = "missing"), na.rm = TRUE),
2
)
expect_equal(
sum(is.na(chr_logical(column = as.character (c("1 - yes", "1", "0 - no",
"missing", NA)),
false_id = "0 - no", true_id = "1 - yes",
na_labels = "missing"))),
2
)
expect_equal(
chr_logical(column = c(
"igen, az is megadom", "nincsen", "nem","DK", "van", "NT/NV", NA),
false_id = "default", true_id = "default",
na_labels = "default"),
c(1,0,0,NA,1, NA, NA)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.