Description Usage Arguments Value Examples
to.indicators
converts a categorical variable into a data.frame
with indicator (0 or 1) variables for each category.
1 | to.indicators(vec, exclude.base = TRUE, base = NULL, prefix = NULL)
|
vec |
a categorical vector. |
exclude.base |
|
base |
a base category removed from the indicator matrix. This option works
only when the |
prefix |
a prefix to be used for column names of the output matrix.
Default is "cat_" if |
This returns an object of matrix
which contains indicators.
1 2 3 4 5 6 | a1 = 4:10;
b1 = c("aa", "bb", "cc");
to.indicators(a1, base = 10);
to.indicators(b1, base = "bb", prefix = "T_");
to.indicators(as.data.frame(b1), base = "bb");
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.