Learn R Programming

frab (version 0.0-6)

table: Tables and frab objects

Description

Various methods and functions to deal with tables in the frab package.

Usage

# S4 method for frab
as.table(x,...)
table_to_frab(x)

Value

Generally return a table or frab.

Arguments

x

Object of class frab or table

...

Further arguments, currently ignored

Author

Robin K. S. Hankin

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.

Examples

Run this code
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()))

Run the code above in your browser using DataLab