# NOT RUN {
## 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])
# }
Run the code above in your browser using DataLab