library (surveyreader)
library(testthat)
context("Convert attachment 4-level description categories.")
test_that("correct conversion takes place", {
expect_equal( rescale_attachment_4 (column =
c("Very attached",
"Fairly attached",
"Not very attached",
"Not at all attached",
"DK", "NT/NV"),
na_labels = "default",
return_class = "character"),
c("very_attached", "attached",
"not_very_attached", "not_attached",
NA, NA)
)
expect_equal( rescale_attachment_4 (column =
c("Very attached",
"Fairly attached",
"Not very attached",
"Not at all attached",
"DK", "NT/NV"),
na_labels = "default",
return_class = "numeric"),
c(2, 1, -1, -2, NA, NA)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.