report.multipleChoice: Report the distributions of several dichotomous variables

View source: R/report.multipleChoice.R

report.multipleChoiceR Documentation

Report the distributions of several dichotomous variables

Description

This function reports the frequencies of a specified event in multiple variables of a dataset. It converts the event of interest to numeric, calculates the frequency of the event, the number of valid and invalid entries for each variable, and optionally attaches variable labels.

Usage

report.multipleChoice(
  data,
  varNames,
  event = 1,
  attachLabels = FALSE,
  dec.freq = 0,
  language = "english"
)

Arguments

data

A data frame or an object of class survey.design from survey package.

varNames

A vector of strings representing the names of the variables in the data frame.

event

A value (numeric or character) representing the event of interest to be reported. This event is transformed to numeric 1 in each specified variable. Default is 1.

attachLabels

Logical, if TRUE, attempts to attach variable labels from the attributes of the data frame. Default is FALSE.

dec.freq

Number of decimal places for frequencies. Defaults is 0. Only used when an object of class survey.design is specified with the parameter data.

language

The language used for displaying the statistics in the frequency table. This parameter accepts two values: english or slovene. Depending on the chosen language, all statistical terms and output will be adjusted accordingly. Default is english.

Value

A data frame with columns representing: 1) the frequency of the event, 2) the percentage of the event, 3) the number of valid (non-NA) entries, 4) the number of invalid (NA) entries for each specified variable.

Author(s)

Marjan Cugmas

Examples

data <- data.frame(A = c(1, 1, 2, NA), B = c(1, 2, 2, 1), C = c(NA, 1, 1, 1))
varNames <- c("A", "B", "C")
report.multipleChoice(data, varNames)

handyReport documentation built on Oct. 8, 2024, 3 p.m.