I am just starting to go beyond the basics of R and come to the point where I need help. I want to restructure some data. Here is an example of an example data frame:
ID Sex Res Contact
1 M MA ABR
1 M MA CON
1 M MA WWF
2 F FL WIT
2 F FL CON
3 X GA XYZ
I want the data to look like this:
ID SEX Res ABR CON WWF WIT XYZ
1 M MA 1 1 1 0 0
2 F FL 0 1 0 1 0
3 X GA 0 0 0 0 1
What are my options? How do I do this in R?
In short, I want to save the values of the CONT column and use them as the column names in the restructured data frame. I want the variable column group to be constant (in the above example, I held the identifier, gender, and constant constant Res).
Also, is it possible to manage values in restructured data? I can save the data as binary. I may need some data to have a value equal to the number of times each contact value for each identifier.