Create dummies for all factors in the data frame:
> students.new <- dummy.data.frame(students, sep = ".") > names(students.new)  "Age" "State.NJ" "State.NY" "State.TX" "State.VA"  "Gender.F" "Gender.M" "Height" "Income"
The students.new data frame now contains all the original variables and the newly added dummy variables. The dummy.data.frame() function has created dummy variables for all four levels of State and two levels of Gender factors. However, we will generally omit one of the dummy variables for State and one for Gender when we use machine learning techniques.
We can use the optional argument all = FALSE to specify that the resulting data frame should contain only the generated dummy variables and none of ...