interact.data {ncpen}R Documentation

Construct Interaction Matrix

Description

interact.data interacts all the data in a data.frame or matrix.

Usage

interact.data(data, base.cols = NULL, exclude.pair = NULL)

Arguments

data

a data.frame or matrix to interact.

base.cols

indicates columns from one category. Interactions among variables from a same base.col will be avoided. For example, if three indicator columns, "ChannelR", "ChannelC" and "ChannelB", are created from a categorical column "Channel", then the interaction among them can be excluded by assigning base.cols=c("Channel"). Multiple base.cols are possible.

exclude.pair

the pairs will be excluded from interactions. This should be a list object of pairs. For example, list(c("a1", "a2"), c("d1", "d2")).

Value

This returns an object of matrix which contains interactions.

Examples

df = data.frame(1:3, 4:6, 7:9, 10:12, 13:15);
colnames(df) = c("aa", "bb", "cc", "dd", "aa2");
df

interact.data(df);
interact.data(df, base.cols = "aa");
interact.data(df, base.cols = "aa", exclude.pair = list(c("bb", "cc")));




[Package ncpen version 1.0.0 Index]