I have dataframe of id of car workshop and cars they fix:
id = c(1,2,3,4,5)
cars = c("Toyota; Fiat","Crysler","Ford; BMW; Audi", "BMW; Porsche; Audi; Fiat; Peugeot", "")
cbind.data.frame(id,cars)
id cars
1 Toyota; Fiat
2 Crysler
3 Ford; BMW; Audi
4 BMW; Porsche; Audi; Fiat; Peugeot
5
I would like to to get it into wide format of 0's and 1's. So my desired output would be:
id Toyota Fiat Crysler Ford BWM Audi Porsche Peugeot
1 1 1 0 0 0 0 0 0
2 0 0 1 0 0 0 0 0
3 0 0 0 1 1 1 0 0
4 0 1 0 0 1 1 1 1
5 0 0 0 0 0 0 0 0
I tried using dplyr::spread
with sep = ";"
parameter, but i dont know how to get those 0/1's as values.
Help will be appreciated!