as.xtabs: Convert objects to xtabs format

Description Usage Arguments Details Value Author(s) Examples

Description

Currently able to convert a data frame or a matrix into an xtabs object.

Usage

1
2
3
4
5
6
7
as.xtabs(x,...)

## S3 method for class 'data.frame'
 as.xtabs(x, rowvar = NULL, colvar = NULL, labels = 1, ...)

## S3 method for class 'matrix'
 as.xtabs(x, rowvar = NULL, colvar = NULL, ...)

Arguments

x

object (typically a data frame) to be converted to xtabs format

rowvar

name of the row variable as character string

colvar

name of the column variable as character string

labels

Column of data frame that contains the lables of the row variable.

...

additional arguments to be passed to or from methods.

Details

The intended use it to convert a two-way contingency table stored in a data frame or a matrix into an xtabs object.

Value

An xtabs object.

Author(s)

Randall Pruim (rpruim@calvin.edu)

Examples

1
2
3
4
# example from example(fisher.test)
df <- data.frame( X=c('Tea','Milk'), Tea=c(3,1), Milk=c(1,3) )
xt <- as.xtabs(df, rowvar="Guess", colvar="Truth"); xt
if (require(vcd)) { mosaic(xt) }

abd documentation built on May 2, 2019, 4:46 p.m.