DescTools (version 0.99.11)

as.matrix.xtabs: Xtabs to Matrix

Description

This function turns an xtabs object into a matrix.

Usage

## S3 method for class 'xtabs':
as.matrix(x, ...)

Arguments

x
an object of class xtabs
...
additional arguments to be passed to or from methods.

Details

xtabs is indeed already a matrix, but won't be converted to a pure matrix by as.matrix.default function, as its classes will remain unchanged. Some functions expecting a pure matrix may fail, when fed with a xtabs object. This function will only kill the classes and the call attribute.

See Also

as.matrix, xtabs

Examples

Run this code
tab <- xtabs( ~ driver + operator, data=d.pizza)

str(tab)
class(tab)

str(as.matrix(tab))
class(as.matrix(tab))

Run the code above in your browser using DataCamp Workspace