Learn R Programming

gRbase (version 1.8-5.1)

df2xtabs: Convert dataframe to contingency table

Description

: Much like xtabs but with more flexibility

Usage

df2xtabs(indata, names = NULL, normalize = "none", smooth = 0)

Arguments

indata

A dataframe.

names

Names of variables defining table; a character vector or a right hand sided formula.

normalize

Either "none", "first" or "all". Should result be normalized, see 'Details' below.

smooth

Should values be smoothed, see 'Details' below.

Examples

Run this code
# NOT RUN {
## Extract arrays from dataframe (much like xtabs() but with more flexibility)
data(cad1) 
df2xtabs(cad1, ~Sex:AngPec:AMI)
df2xtabs(cad1, c("Sex", "AngPec", "AMI"))
df2xtabs(cad1, c(1, 2, 3))
# }

Run the code above in your browser using DataLab