Skip to content

The compile function generates a comprehensive CSV or statistics data frame from survey data, combining crosstabs and/or statistics for each pair of row and column variables.

Usage

compile(
  data,
  rowVars,
  colVars,
  weight,
  format = c("csv", "statistics"),
  save = TRUE,
  name = "table"
)

Arguments

data

A data frame containing survey data.

rowVars

A vector of names of independent variables, each represented in rows.

colVars

A vector of names of dependent variables, each represented in columns.

weight

Optional variable containing weight factors for the analysis.

format

The desired output format: 'csv' for a formatted CSV file, or 'statistics' for a statistical summary (default is 'csv').

save

Logical; if TRUE, the results are saved to a CSV file (default is TRUE).

name

The name of the output file (without extension) when save is TRUE (default is 'table').

Value

If save is FALSE, returns a data frame containing the compiled results. If save is TRUE, the function saves the results to a CSV file and does not return a value.

Examples

if (FALSE) { # \dontrun{
  # Example: Compile crosstabs with CSV output using weighted data
  compile(data = dataset,
          rowVars = c("Q1", "Q2"),
          colVars = c("Gender", "VI"),
          weight = "wgtvar",
          name = "crosstabs")
} # }