table {frab} | R Documentation |
Tables and frab objects
Description
Various methods and functions to deal with tables in the frab package.
Usage
## S4 method for signature 'frab'
as.table(x,...)
table_to_frab(x)
Arguments
x |
Object of class |
... |
Further arguments, currently ignored |
Details
If a frab
object has non-negative entries it may be interpreted
as a table. However, in base R, table
objects do not have
sensible addition methods which is why the frab package is
needed.
Function is.1dtable()
checks for its argument being a
one-dimensional table. The idea is that a table like
table(sample(letters,30,TRUE))
, being a table of a single
observation, is accepted but a table like
table(data.frame(rnorm(20)>0,rnorm(20)>0))
is not acceptable
because it is a two-dimensional contingency table.
Value
Generally return a table or frab.
Note
The order of the entries may be changed during the coercion, as per
disordR discipline. Function as.frab()
takes a
table, dispatching to table_to_frab()
.
Author(s)
Robin K. S. Hankin
Examples
X <- table(letters[c(1,1,1,1,2,3,3)])
Y <- table(letters[c(1,1,1,1,3,4,4)])
Z <- table(letters[c(1,1,2,3,4,5,5)])
X+Y # defined but nonsense
# X+Z # returns an error
as.frab(X) + as.frab(Y) # correct answer
plot(as.table(rfrab()))