Sorry for my novelty in the world of R, thank you in advance for your help.
I would like to analyze the data from the experiment.
The data comes in a long format, and it needs to be converted to wide, but I can’t determine exactly how to do it. Most melt / cast and rebuild examples deal with much simpler data frames.
Each time a subject answers a question about an experiment, his identifier, location, age and gender are recorded on one line, then his experimental data on a number of questions are entered next to these variables. Here, they can answer any number of questions in the experiment, and they can answer different subjects (this is quite difficult, but it should be so).
Raw data looks something like this:
User_id, location, age, gender, Item, Resp 1, CA, 22, M, A, 1 1, CA, 22, M, B, -1 1, CA, 22, M, C, -1 1, CA, 22, M, D, 1 1, CA, 22, M, E,-1 2, MD, 27, F, A, -1 2, MD, 27, F, B, 1 2, MD, 27, F, C, 1 2, MD, 27, F, E, 1 2, MD, 27, F, G, -1 2, MD, 27, F, H, -1
I would like to modify this data so that each user is on the same line to look like this:
User_id, location, age, gender, A, B, C, D, E, F, G, H 1, CA, 22, M, 1, -1, -1, 1, -1, 0, 0, 0, 2, MD, 27, F, -1, 1, 1, 1, 0, 1, -1, -1
I think it’s just a matter of finding the right equation of change, but I have been with him for a couple of hours, and I can’t get what I want, it also looks like since most of the examples do not have duplicate demographic data, and therefore they can simply be turned easier. It is unfortunate if I missed something simple.