Learn R Programming

userfriendlyscience (version 0.7.2)

multiResponse: Generate a table for multiple response questions

Description

The multiResponse function mimics the behavior of the table produced by SPSS for multiple response questions.

Usage

multiResponse(data,
              items = NULL,
              regex = NULL,
              endorsedOption = 1)

Arguments

data

Dataframe containing the variables to display.

items, regex

Arguments items and regex can be used to specify which variables to process. items should contain the variable (column) names (or indices), and regex should contain a regular expression used to match to the column names of the dataframe. If none is provided, all variables in the dataframe are processed.

endorsedOption

Which value represents the endorsed option (note that producing this kind of table requires dichotomous items, where each variable is either endorsed or not endorsed, so this is also a way to treat other variables as dichotomour).

Value

A dataframe with columns Option, Frequency, Percentage, and Percentage of (X) cases, where X is the number of cases.

References

This function is based on the excellent and extensive Stack Exchange answer by Ananda Mahto at https://stackoverflow.com/questions/9265003/analysis-of-multiple-response.

Examples

Run this code
# NOT RUN {
multiResponse(mtcars, c('vs', 'am'));
# }

Run the code above in your browser using DataLab