Learn R Programming

sdcTable (version 0.29)

createJJFormat: Create input for jj_format

Description

This function transforms a '>sdcProblem object into a list that can be used as input for writeJJFormat() to write a problem in "JJ-format" to disk.

Usage

createJJFormat(x)

Arguments

x

a '>sdcProblem object

Value

an input suitable for writeJJFormat()

Examples

Run this code
# NOT RUN {
data("microData1", package = "sdcTable")

# create hierarchies
dimList <- list(
  region = hier_create(root = "Total", nodes = LETTERS[1:4]),
  gender = hier_create(root = "Total", nodes = c("male", "female")))

# create a problem instance
prob <- makeProblem(
  data = microData1,
  dimList = dimList,
  numVarInd = "val")

# create suitable input for `writeJJFormat`
inp <- createJJFormat(prob); inp

# write files to disk
# frequency table by default
writeJJFormat(inp, path = file.path(tempdir(), "prob_freqs.jj"), overwrite = TRUE)

# or using the numeric variable `val` previously specified
writeJJFormat(inp, tabvar = "val", path = file.path(tempdir(), "prob_val.jj"), overwrite = TRUE)
# }

Run the code above in your browser using DataLab