I have data frame dat1 and I want to have data frame dat2. How convert this data frame dat1 to dat2 build 1 and 0.
s <- c("A","B","C","D","E")
h <- c("H1","H2","H1","H3","H4")
dat1 <- data.frame(s,h)
dat2:
H1 H2 H3 H4
A 1 0 0 0
B 0 1 0 0
C 1 0 0 0
E 0 0 1 0
F 0 0 0 1