multiResponse: Generate a table for multiple response questions

Description Usage Arguments Value Author(s) References Examples

View source: R/multiResponse.R

Description

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

Usage

1
2
3
4
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.

Author(s)

Ananda Mahto; implemented in this package (and tweaked a bit) by Gjalt-Jorn Peters.

Maintainer: Gjalt-Jorn Peters <gjalt-jorn@userfriendlyscience.com>

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

1
multiResponse(mtcars, c('vs', 'am'));

Example output

Registered S3 method overwritten by 'GGally':
  method from   
  +.gg   ggplot2
Registered S3 methods overwritten by 'lme4':
  method                          from
  cooks.distance.influence.merMod car 
  influence.merMod                car 
  dfbeta.influence.merMod         car 
  dfbetas.influence.merMod        car 
  Option Frequency Percentage of responses Percentage of (32) cases
1     vs        14                51.85185                   43.750
2     am        13                48.14815                   40.625
3  Total        27               100.00000                   84.375

userfriendlyscience documentation built on May 2, 2019, 1:09 p.m.