title: Is there a better way to write this if-else statement?
body: <p>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.</p>
  
  <pre><code>##Set up boolean values##
  norm.knnN$gearbox[norm.knnN$gearbox=="automatic"] = 1
  norm.knnN$gearbox[norm.knnN$gearbox=="manual"] = 0
  norm.knnN$gearbox = as.numeric(norm.knnN$gearbox)
  
  norm.knnN$bus= ifelse(norm.knnN$vehicleType=="bus",1,0)
  norm.knnN$cabrio= ifelse(norm.knnN$vehicleType=="cabrio",1,0)
  norm.knnN$coupe= ifelse(norm.knnN$vehicleType=="coupe",1,0)
  norm.knnN$limousine= ifelse(norm.knnN$vehicleType=="limousine",1,0)
  norm.knnN$otherCar= ifelse(norm.knnN$vehicleType=="other",1,0)
  norm.knnN$small_car= ifelse(norm.knnN$vehicleType=="small_car",1,0)
  norm.knnN$station_wagon= ifelse(norm.knnN$vehicleType=="station_wagon",1,0)
  norm.knnN$suv= ifelse(norm.knnN$vehicleType=="suv",1,0)
  norm.knnN$vehicleType = NULL
  
  
  norm.knnN$cng= ifelse(norm.knnN$fuelType=="cng",1,0)
  norm.knnN$diesel= ifelse(norm.knnN$fuelType=="diesel",1,0)
  norm.knnN$electric= ifelse(norm.knnN$fuelType=="electric",1,0)
  norm.knnN$hybrid= ifelse(norm.knnN$fuelType=="hybrid",1,0)
  norm.knnN$lpg= ifelse(norm.knnN$fuelType=="lpg",1,0)
  norm.knnN$otherFuel= ifelse(norm.knnN$fuelType=="other",1,0)
  norm.knnN$petrol= ifelse(norm.knnN$fuelType=="petrol",1,0)
  norm.knnN$fuelType = NULL
  
  
  norm.knnN$audi= ifelse(norm.knnN$brand=="audi",1,0)
  norm.knnN$bmw= ifelse(norm.knnN$brand=="bmw",1,0)
  norm.knnN$mercedes_benz= ifelse(norm.knnN$brand=="mercedes_benz",1,0)
  norm.knnN$opel= ifelse(norm.knnN$brand=="opel",1,0)
  norm.knnN$volkswagen= ifelse(norm.knnN$brand=="volkswagen",1,0)
  norm.knnN$brand = NULL
  
  
  norm.knnN$notRepairedDamage[norm.knnN$notRepairedDamage=="yes"] = 1
  norm.knnN$notRepairedDamage[norm.knnN$notRepairedDamage=="no"] = 0
  norm.knnN$notRepairedDamage = as.numeric(norm.knnN$notRepairedDamage)
  </code></pre>