multiVarFreq: Generate a table collapsing frequencies of multiple variables

Description Usage Arguments Value Author(s) See Also Examples

View source: R/multiVarFreq.R

Description

This function can be used to efficiently combine the frequencies of variables with the same possible values. The frequencies are collapsed into a table with the variable names as row names and the possible values as column (variable) names.

Usage

1
2
3
4
multiVarFreq(data,
             items = NULL,
             labels = NULL,
             sortByMean = TRUE)

Arguments

data

The dataframe containing the variables.

items

The variable names.

labels

Labels can be provided which will be set as row names when provided.

sortByMean

Whether to sort the rows by mean value for each variable (only sensible if the possible values are numeric).

Value

The resulting dataframe, but with class 'multiVarFreq' prepended to allow pretty printing.

Author(s)

Gjalt-Jorn Peters

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

See Also

table, freq

Examples

1
multiVarFreq(mtcars, c('gear', 'carb'));

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 
     1  2  3  4 5 6 8
carb 7 10  3 10   1 1
gear      15 12 5    

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