I have the following data that looks like this:
> View(mydata)
Gender Race Agegroup Date ..... #m columns
#1 Male Asian 1 2015/04/20 .....
#2 Female White 2 2015/04/15 .....
.
.
#n rows
I want to transform mydata into this format:
Gender=Male Gender=Female Race=Asian Race=White Agegroup = 1 Agegroup = 2 ......
1 0 0 0 1 0
0 1 0 1 0 1
. . . . . .
. . . . . .
I am new to R, I know for loop would work but is there a cleaner way to do this?