tests/testthat/test-makeProblem.r

context("test makeProblem()")

test_that("makeProblem works", {
  skip_on_cran()
  utils::data("microdata1", package = "sdcTable")
  dim.region <- data.frame(
    levels = c("@", "@@", "@@", "@@", "@@"),
    codes = c("Total", "A", "B", "C", "D"),
    stringsAsFactors = FALSE
  )
  dim.gender <- data.frame(
    levels = c("@", "@@", "@@"),
    codes = c("Total", "male", "female"),
    stringsAsFactors = FALSE
  )
  dimList <- list(region = dim.region, gender = dim.gender)
  dimVarInd <- c(1, 2)
  freqVarInd <- numVarInd <- weightInd <- sampWeightInd <- NULL

  problem <- makeProblem(
    data = microdata1,
    dimList = dimList,
    dimVarInd = dimVarInd,
    freqVarInd = freqVarInd,
    numVarInd = numVarInd,
    weightInd = weightInd,
    sampWeightInd = sampWeightInd
  )

  expect_is(problem, "sdcProblem")
  expect_equal(get.problemInstance(problem@problemInstance, "nrVars"), 15)
})

Try the sdcTable package in your browser

Any scripts or data that you put into this service are public.

sdcTable documentation built on Aug. 11, 2023, 9:06 a.m.