Created
October 22, 2019 16:12
-
-
Save thoolihan/acd7db30f7ee5e852234f179aa1cc9d9 to your computer and use it in GitHub Desktop.
creating ordinal numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# casting as integer | |
int_cyl <- as.integer(mtcars$cyl) | |
int_cyl | |
# creating a factor | |
factor_cyl <- as.factor(mtcars$cyl) | |
factor_cyl | |
# flag columns / dummy variables | |
library(caret) | |
trans <- dummyVars(~ as.factor(cyl), data=mtcars) | |
predict(trans, mtcars) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment