tests/testthat/test-demographics.R

test_that("number rows & columns correct", {
  expect_equal(
    dim(demographics),
    c(3560L, 9L)
  )
})

test_that("variable names correct", {
  expect_equal(
    names(demographics),
    c(
      "who", "age", "is_hispanic", "race", "job", "is_living_stable",
      "education", "marital", "is_male"
    )
  )
})

test_that("variable class correct", {
  expect_equal(
    sapply(demographics, class),
    c(
      who = "integer", age = "numeric", is_hispanic = "factor", race = "factor",
      job = "factor", is_living_stable = "factor", education = "factor",
      marital = "factor", is_male = "factor"
    )
  )
})

Try the public.ctn0094data package in your browser

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

public.ctn0094data documentation built on Oct. 1, 2023, 5:08 p.m.