dat2fre {confreq}R Documentation

dataset to pattern frequency conversion

Description

Given a dataset this function returns a (response) pattern frequencies table representation of it.

Usage

dat2fre(
  x,
  katorder = FALSE,
  caseorder = TRUE,
  kat = NULL,
  codes = NULL,
  wgt = NULL,
  ...
)

Arguments

x

an object of class "matrix" or "data.frame". If x is a "data.frame" each variable (column) must be an integer or a factor. If x is a "matrix" it is assumed that the categories for each variable in x start with 1 – there is no check for that !!!

katorder

logical with default set to katorder==FALSE. When set to katorder==TRUE variables are ordered according to their number of categories (variable with most categories is the rightmost variable) in the resulting object.

caseorder

logical with default set to caseorder==TRUE. When set to caseorder==FALSE configurations are only ordered according to the categories of the rightmost variable in the resulting object.

kat

ignored when x is a data.frame! If x is a "matrix" the optional argument kat must be an integer vector defining the number of categories for every variable in x (in the respective order). If left empty the (max) number of categories is estimated from the data given in x.

codes

a list with character vectors containing coding for integers in matrix (if x is a numeric matrix). If codes is not empty (and the argument x is an object of class "matrix") the return object will be pattern frequencies table as data.frame.

wgt

a numerical vector of survey weights to weight the cases (rows) in x

...

other parameters passed through to table (in case of x being a data.frame) or to tabulate (in case of x being a matrix).

Details

To use survey weights a vector of positive numeric values with length matching the number of rows in x must be assigned to the argument wgt. The individual case weights are then aggregated (respective sum of weights) for each pattern observed in the data (assigned to argument x).

Value

An object of class c("data.frame","Pfreq") containing the (response) pattern frequencies table representation of the given dataset in the argument x.

References

No references in the moment

Examples

#######################################
data(suicide)# loading data in data frame (702 cases) representation 
dat2fre(suicide) # converting it into a pattern frequencies table

########### 
#######################################
data(LienertLSD)# loading example pattern frequencies table ..
test<-fre2dat(LienertLSD)# and coverting it into a simple (data) matrix
test<-test[sample(c(1:65),65),] # making a messy order 
############
dat2fre(test) # making a proper ordered pattern frequencies table again
##### try it with a data.frame too!
#######################################

[Package confreq version 1.6.1-1 Index]