Description Usage Arguments Value Examples
This automates the processes of to.indicators
and interact.data
.
First, it converts categorical variables to a series of indicators.
All other numerical and logical variables are preserved.
Then, if interact.all == TRUE
, all the variables are interacted.
1 2 |
df |
a |
base |
a base category removed from the indicator variables. This |
interact.all |
indicates whether to interact all the columns ( |
base.cols |
indicates columns derived from a same column. For example, if |
exclude.pair |
the pairs will be excluded from interactions. This should be a |
This returns an object of matrix
.
1 2 3 4 5 6 7 8 9 10 11 12 13 | df = data.frame(num = c(1, 2, 3, 4, 5),
ctr = c("K", "O", "R", "R", "K"),
logi = c(TRUE, TRUE, FALSE, FALSE, TRUE),
age = c(10, 20, 30, 40, 50),
age_sq = c(10, 20, 30, 40, 50)^2,
loc = c("b", "a", "c", "a", "b"),
FTHB = c(1,0,1,0,1),
PRM = c(0,1,0,1,0),
PMI = c(1,1,0,0,0));
to.ncpen.x.mat(df, interact.all = TRUE,
base.cols = c("age"),
exclude.pair = list(c("FTHB", "PRM")));
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.