tests/testthat/test-rescale_trust.R

library (surveyreader)
library(testthat)
context("Convert trust description categories.")

rescale_benefit_2 (column =c("DK",
                             "Would benefit",
                             "Would not benefit"),
                   underscore = FALSE,
                   return_class = "character")

rescale_benefit_2 (column =c("DK","Would benefit",
                             "Would not benefit"),
                   return_class = "numeric")

test_that("correct conversion takes place", {
  expect_equal(rescale_trust (column = c("DK",
                                           "Tend to trust",
                                           "Tend not to trust",
                                           "tend to trust"),
                                       return_class = "character"),
  c(NA, "trust", "distrust", "trust")
  )
  expect_equal(rescale_trust (column =
                                    c("DK",
                                      "Tend to trust",
                                      "Tend not to trust",
                                      "tend to trust"),
                                     return_class = "numeric"),
    c(NA, 1, 0, 1)
  )
})
antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.