Learn R Programming

anacor (version 1.1-4)

expandFrame: Expand Matrix

Description

This utility function expands a matrix or data frame to an indicator supermatrix and optionally converts this to a data frame again. By default NA becomes zero and constant rows and columns are eliminated.

Usage

expandFrame(tab, clean = TRUE, zero = TRUE, returnFrame = TRUE)

Arguments

tab

Data frame (factors). Missings are coded as NA.

clean

If TRUE, rows and colums with 0 margins in data frame are deleted.

zero

If TRUE, NA's are replaced by 0.

returnFrame

If TRUE, a data frame is returned; if FALSE a matrix.

See Also

burtTable, mkIndiList

Examples

Run this code
# NOT RUN {
## sleeping bags
data(sleeping)
sleeping_cat <- sleeping
temp_cat <- cut(sleeping$Temperature, c(-20, -1, 7), labels = c("warm", "cold")) 
sleeping_cat$Temperature <- temp_cat
weight_cat <- cut(sleeping$Weight, c(700, 1100, 2200), labels = c("light", "heavy")) 
sleeping_cat$Weight <- weight_cat
price_cat <- cut(sleeping$Price, c(100, 250, 350, 700), 
labels = c("cheap", "medium", "expensive"))  
sleeping_cat$Price <- price_cat
sleeping_cat
expandFrame(sleeping_cat)

# }

Run the code above in your browser using DataLab