data = data.frame("id"=1:40,
"group"=1:5,
"score"=sample(1:4,10,r=T))
table(data[which(data$group==1),]$score)
WANT=data.frame("group"=1:5,
"score1"=c(0,4,0,4,0),
"score2"=c(4,0,0,4,0),
"score3"=c(0,4,0,4,0),
"score4"=c(0,0,4,4,0))
In data I have "score" but I want to make separate columns for each "score" and then sum up as shown here.
I also want to have my complete data frame 'WANT' and put 0s if there aren't any people but otherwise keep the same structure in terms of rows.