I am wondering if there is an easier way to create these variables than what I am doing? I am trying to turn the values of my vehicle type variable in to variables themselves.>
It is better to use dplyr's syntax. There are some literature to learn how to use the syntax. (https://genomicsclass.github.io/book/pages/dplyr_tutorial.html)
In the syntax, I usually use case_when function to make several condition rather than ifelse function.
norm.knnN$gearbox[norm.knnN$gearbox=="automatic"] = 1
norm.knnN$gearbox[norm.knnN$gearbox=="manual"] = 0
It would be changed to this syntax I mentioned.
norm.knnN %>%
mutate(gearbox = case_when(
gearbox == "automatic" ~ 1,
gearbox == "manual" ~ 0,
TRUE ~ NA))