tests/testthat/test-rescale_situation.R

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

test_that("correct conversion takes place", {
  expect_equal(rescale_situation (column =
                                         c("DK",
                                           "Very good",
                                           "Very bad",
                                           "Rather good",
                                           "Rather bad"),
                                       underscore = FALSE,
                                       return_class = "character"),
  c(NA ,"very good" ,"very bad" ,
    "rather good","rather bad")
  )
  expect_equal(rescale_situation (column =
                                       c("DK",
                                         "Very good",
                                         "Very bad",
                                         "Rather good",
                                         "Rather bad"),
                                     return_class = "numeric"),
    c(NA ,2,-2,1,-1)
  )
})
antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.