Description Usage Arguments Value Examples
Convert values of categorical variables into indicator matrix
1 | indicator(x)
|
x |
A data frame of categorical data coded in numbers. |
Dummy_variables
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Long form
data(PTSD)
PTSD <- as.data.frame(PTSD)
# Transform a string or continuous class variable into factor
PTSD[,2:4] <- apply(PTSD[,2:4], 2, function(x) ifelse(x >= 3, 1, 0))
PTSD[,5] <- ifelse(PTSD[,5] >= 6 , 1, 0)
PTSD <- data.frame(lapply(PTSD[,-1], function(x) as.factor(x)))
indicator(PTSD)
## Wide form
data(Depression)
str(Depression)
indicator(Depression[,-1])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.