Learn R Programming

questionr (version 0.2)

cross.multi.table: Two-way frequency table between a multiple choices question and a factor

Description

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

Usage

cross.multi.table(df, crossvar, ...)

Arguments

df
data frame with the binary variables
crossvar
factor to cross the multiple choices question with
...
arguments passed to multi.table

Value

  • Object of class table.

Details

See the multi.table help page for details on handling of the multiple choices question and corresponding binary variables.

See Also

multi.table, multi.split, table

Examples

Run this code
## Sample data frame
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)
## Two-way frequency table on 'music' variables by sex
cross.multi.table(df[,c("jazz", "rock","electronic")], df$sex, true.codes=list("Y"))

Run the code above in your browser using DataLab