context("codebookItemTxtHeader")
ds <- readRDS(test_path("fixtures/example_dataset.rds"))
test_that("codeBookItemTxtHeader CategoricalVariable", {
res <- codeBookItemTxtHeader(ds$q1)
expect_equal(
res,
"\\textbf{Pet}\\hfill\\textbf{\\ttfamily{q1}}\n\n{\\small Categorical}\n\n"
)
})
test_that("codeBookItemTxtHeader CategoricalArrayVariable", {
res <- codeBookItemTxtHeader(ds$petloc)
expect_equal(
res,
"\\textbf{Pets by location}\\hfill\\textbf{\\ttfamily{petloc}}\n\n{\\small Grid}\n\n"
)
})
test_that("codeBookItemTxtHeader MultipleResponseVariable", {
res <- codeBookItemTxtHeader(ds$allpets)
expect_equal(
res,
"\\textbf{All pets owned}\\hfill\\textbf{\\ttfamily{allpets}}\n\n{\\small Multiple Response}\n\n" # nolint
)
})
test_that("codeBookItemTxtHeader NumericVariable", {
res <- codeBookItemTxtHeader(ds$ndogs)
expect_equal(
res,
"\\textbf{Number of dogs}\\hfill\\textbf{\\ttfamily{ndogs}}\n\n{\\small Numeric}\n\n"
)
})
test_that("codeBookItemTxtHeader DatetimeVariable", {
res <- codeBookItemTxtHeader(ds$wave)
expect_equal(
res,
"\\textbf{Wave}\\hfill\\textbf{\\ttfamily{wave}}\n\n{\\small Date}\n\n"
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.