I have a large data set in which i have a column which contains 5 different types of values. I want to create 5 different columns( 1 for each value) based on the column. Additionally, each row in those columns should contain either 1 or 0 based on whether another column contained that value For example suppose this is the data frame
l1=data.frame(c1= c("A","A","B","B","B","C"), c2 = c("Blue","Green","Red","yellow","Black","Blue"))
The output should be
l2=data.frame(c1=c("A","A","B","B","B","C"), Blue=c(1,0,0,0,0,1),Green=c(0,1,0,0,0,0),Red=c(0,0,1,0,0,0),Yellow=c(0,0,0,1,0,0),Black=c(0,0,0,0,1,0))
Thank you!