library (surveyreader)
library(testthat)
context("Converting multiple choice character values to numeric values.")
mc_column_1 <- c("first option", NA, "first option", "NA" )
mc_column_2 <- c(NA, "second option", NA, "NA")
test_that("correct numeric conversion takes place", {
expect_equal(
sum (mc_indicator ( column = mc_column_1,
selected = 1,
unselected = 0,
missing = 0,
na_id = NA), na.rm = FALSE),
3
)
expect_equal(
sum (mc_indicator ( column = mc_column_1,
selected = 1,
unselected = 0,
missing = 0,
na_id = "NA"), na.rm = FALSE),
2
)
expect_equal(
sum (mc_indicator ( column = mc_column_2,
selected = 2,
missing = NA,
na_id = "NA"), na.rm = TRUE),
2
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.