The data structure I'm looking at is:
head(data)
ID Gender Location Generation Question Response
1 2 Male South America Generation X Q0. Vote in the upcoming election? 0: No
2 2 Male South America Generation X Q1. Pulse Rate 0: No
3 2 Male South America Generation X Q2. Metabolism 0: No
4 2 Male South America Generation X Q3.Blood Pressure 1: Yes
5 2 Male South America Generation X Q4. Temperature 0: No
6 2 Male South America Generation X Q5. Galvanic Skin Response 1: Yes
The column headers in this data frame are as follows:
> colnames(data)
[1] "ID" "Gender" "Location" "Generation" "Question" "Response"
The Question
as the header contains the questions asked and so does the Responses
. How I'd want to look at it is:
> colnames(final_data)
[1] "ID" "Gender"
[3] "Location" "Generation"
[5] "Q0. Vote in the upcoming election?" "Q1. Pulse Rate"
[7] "Q134. Good Job Skills" "Q135. Sense of Humor"
[9] "Q136. Intelligence" "Q137.Can Play Jazz"
[11] "Q138.Likes the Beatles" "Q139. Snobbiness"
[13] "Q140.Ability to lift heavy objects" "Q141.Grace under pressure"
[15] "Q142.Grace on the dance floor" "Q143.Likes animals"
[17] "Q144.Makes good coffee" "Q145.Eats all his/her vegetables"
[19] "Q2. Metabolism" "Q3.Blood Pressure"
[21] "Q4. Temperature" "Q5. Galvanic Skin Response"
[23] "Q6. Breathing" "Q7. Perspiration"
[25] "Q8.Pupil Dilation" "Q9. Adrenaline Production"
Currently I have the data which records the attributes for each ID in a single row. Essentially it means that each row has attributes for only one unique ID.
I saw another question here but failed to understand it. Can anyone please help?