table function

Tables and frab objects

Tables and frab objects

Various methods and functions to deal with tables in the frab

package.

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

Arguments

  • x: Object of class frab or table
  • ...: Further arguments, currently ignored

Details

If a frab object has non-negative entries it may be interpreted as a table. However, in base , 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.

Returns

Generally return a table or frab.

Author(s)

Robin K. S. Hankin

Note

The order of the entries may be changed during the coercion, as per list("disordR") discipline. Function as.frab() takes a table, dispatching to table_to_frab().

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()))
  • Maintainer: Robin K. S. Hankin
  • License: GPL (>= 2)
  • Last published: 2024-07-24