interact.data: Construct Interaction Matrix

Description Usage Arguments Value Examples

View source: R/ncpen_util.R

Description

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

Usage

1
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

1
2
3
4
5
6
7
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")));

ncpen documentation built on May 1, 2019, 9:21 p.m.