View source: R/Dataframe2BinaryMatrix.R
Dataframe2BinaryMatrix | R Documentation |
Converts a Data Frame into a Binary Data Matrix
Dataframe2BinaryMatrix(dataf, cuttype = "Median", cut = NULL, BinFact = TRUE)
dataf |
data.frame to be converted |
cuttype |
Type of cut point for continuous variables. Must be "Median" or "Mean". Does not have any effect for factors |
cut |
Personalized cut value for continuous variables. |
BinFact |
Should I treat a factor with two levels as binary. This means that only a single dummy rather than two is used |
The function converts a data frame into a Binary Data Matrix (A matrix with entries either 0 or 1).
Factors with two levels are directly transformed into a column of 0/1 entries.
Factors with more than two levels are converted into a binary submatrix with
as many rows as x
and as many columns as levels or categories. (Indicator matrix)
Integer Variables are treated as factors
Continuous Variables are converted into binary variables using a cut point that can be the median, the mean or a value provided by the user.
A Binary Data Matrix.
Jose Luis Vicente Villardon
data(spiders)
Dataframe2BinaryMatrix(spiders)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.