Transpose dataset and counting occurrences in R : The original dataset contains survey data in long form, like

T Q1  Q2  Q3    
M1 3 5 4  
M1 3 1 3  
M1 1 3 1  
M2 4 4 2  
M2 2 2 3  
M2 5 5 5

Where *T* is the type of respondents and *Q1--Q3* are the questions, and the cell value corresponds to their agreement level on a *1--5* Likert 
scale.

**What I want**  
T Q A1 A2 A3 A4 A5  
M1 Q1 1 0 3 0 0  
M2 Q1 0 1 0 1 1  
M1 Q2 1 0 1 0 1  
M2 Q2 0 1 0 1 1  
M1 Q3 1 0 1 1 0  
M2 Q3 0 1 1 0 1

Where *A1--A5* are the possible answers (1--5 Likert) and the cell value contains the frequency of these answers for each group M1 and M2.

I won
