fre2tab: pattern frequency to table conversion

View source: R/fre2tab.R

fre2tabR Documentation

pattern frequency to table conversion

Description

Given data as pattern frequencies (object of class class c("data.frame","Pfreq", see function dat2fre) this function returns a typical array representation (class "table" , see table) of it.

Usage

fre2tab(patternfreq, form = NULL)

Arguments

patternfreq

an object of class c("data.frame","Pfreq")

form

a formula object with possibly both left and right hand sides specifying the order of the variables in the resulting table. At default ((formula=NULL)) all variables in (x) are used in their respective order.

Details

This function was introduced in order to connect the typical confreq data representation in the objects of the class c("data.frame","Pfreq"), see function dat2fre, to the R-typical array representation as it exists in objects of the "table" class, see table. This array representation of multi-dimensional contingency tables is used more universally in R – e.g. also in the R package vcd, see the examples section below.

It is assumed, that the last column of the object patternfreq represents the frequencies of the (response) pattern represented by the other columns in patternfreq.

Value

An object of class "table" see table.

References

No references at the moment

Examples

#######################################
data(LienertLSD)# loading example pattern frequencies table
fre2tab(LienertLSD)# coverting it into a table

### examples using functions from package vcd
data(Lienert1978)# loading example pattern frequencies table
fre2tab(Lienert1978)# coverting it into a table
strucplot(fre2tab(Lienert1978))# plotting data with 'vcd'
structable(fre2tab(Lienert1978),direction = "v")# flatten table (vertical) with 'vcd'

# changing the vertical grouping when flattening the table by unsing a 'formula':
structable(fre2tab(Lienert1978, form=~Group + Student + Teacher),direction = "v")# flatten table

confreq documentation built on Nov. 13, 2022, 9:05 a.m.