as.matrix.xtabs | R Documentation |
This function converts an xtabs
object to a matrix
.
## S3 method for class 'xtabs'
as.matrix(x, ...)
x |
an object of class |
... |
additional arguments to be passed to or from methods. |
An xtabs
object is indeed already a matrix, but won't be converted to a pure matrix by as.matrix.default
function, as its class definition will remain unchanged. Some functions expecting a pure matrix may fail, when fed with a xtabs
object.
as.matrix.xtabs
will drop the classes and the call attribute.
Note that unclass
would as well discard the classes xtabs
and table
, but retain the "call"
attribute.
Andri Signorell <andri@signorell.net>
as.matrix
, xtabs
, unclass
tab <- xtabs( ~ driver + operator, data=d.pizza)
str(tab)
class(tab)
str(as.matrix(tab))
class(as.matrix(tab))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.