# multi.table: One-way frequency table for multiple choices question In questionr: Functions to Make Surveys Processing Easier

## Description

This function allows to generate a frequency table from a multiple choices question. The question's answers must be stored in a series of binary variables.

## Usage

 ```1 2``` ```multi.table(df, true.codes = NULL, weights = NULL, digits = 1, freq = TRUE) ```

## Arguments

 `df` data frame with the binary variables `true.codes` optional list of values considered as 'true' for the tabulation `weights` optional weighting vector `digits` number of digits to keep in the output `freq` add a percentage column

## Details

The function is applied to a series of binary variables, each one corresponding to a choice of the question. For example, if the question is about seen movies among a movies list, each binary variable would correspond to a movie of the list and be true or false depending of the choice of the answer.

By default, only '1' and 'TRUE' as considered as 'true' values fro the binary variables, and counted in the frequency table. It is possible to specify other values to be counted with the `true.codes` argument. Note than '1' and 'TRUE' are always considered as true values even if `true.codes` is provided.

If `freq` is set to TRUE, a percentage column is added to the resulting table. This percentage is computed by dividing the number of TRUE answers for each value by the total number of (potentially weighted) observations. Thus, these percentages sum can be greater than 100.

## Value

Object of class table.

`cross.multi.table`, `multi.split`, `table`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```## Sample data frame set.seed(1337) sex <- sample(c("Man","Woman"),100,replace=TRUE) jazz <- sample(c(0,1),100,replace=TRUE) rock <- sample(c(TRUE, FALSE),100,replace=TRUE) electronic <- sample(c("Y","N"),100,replace=TRUE) weights <- runif(100)*2 df <- data.frame(sex,jazz,rock,electronic,weights) ## Frequency table on 'music' variables multi.table(df[,c("jazz", "rock","electronic")], true.codes=list("Y")) ## Weighted frequency table on 'music' variables multi.table(df[,c("jazz", "rock","electronic")], true.codes=list("Y"), weights=df\$weights) ## No percentages multi.table(df[,c("jazz", "rock","electronic")], true.codes=list("Y"), freq=FALSE) ```

### Example output

```            n %multi
jazz       49     49
rock       53     53
electronic 57     57
n %multi
jazz       45.2   49.0
rock       47.1   50.9
electronic 53.9   58.4
jazz       rock electronic
49         53         57
```

questionr documentation built on Nov. 17, 2017, 7:19 a.m.