title: Reshaping data in R . Is it possible to have two "value variables"
body: <p>I am struggling with reshape package looking for a way    “cast” a dataframe but with two (or more)  values in “value.var”. </p>
  
  <p>Here an example of what I want to achieve. </p>
  
  <pre><code>df &lt;- data.frame( StudentID = c("x1", "x10", "x2", 
                              "x3", "x4", "x5", "x6", "x7", "x8", "x9"),
                StudentGender = c('F', 'M', 'F', 'M', 'F', 'M', 'F', 'M', 'M', 'M'),
                ExamenYear    = c('2007','2007','2007','2008','2008','2008','2008','2009','2009','2009'),
                Exam          = c('algebra', 'stats', 'bio', 'algebra', 'algebra', 'stats', 'stats', 'algebra', 'bio', 'bio'),
                participated  = c('no','yes','yes','yes','no','yes','yes','yes','yes','yes'),  
                passed      = c('no','yes','yes','yes','no','yes','yes','yes','no','yes'),
                stringsAsFactors = FALSE)
  </code></pre>
  
  <p>From df  I can create the following dataframe : </p>
  
  <pre><code>tx &lt;- ddply(df, c('ExamenYear','StudentGender'), summarize,
          participated = sum(participated      == "yes"),
          passed   = sum(passed      == "yes"))
  </code></pre>
  
  <p>In the reshape logic, I have two <strong>“value variables”</strong> participated  and passed </p>
  
  <p>I am looking for way to combine – in one dataframe – the following information : </p>
  
  <pre><code> dcast(tx, formula = ExamenYear ~ StudentGender, value.var = 'participated')
   dcast(tx, formula = ExamenYear ~ StudentGender, value.var = 'passed')
  </code></pre>
  
  <p>The end table I am trying to create would look like this </p>
  
  <pre><code>tempTab1 &lt;- dcast(tx, formula = ExamenYear ~ StudentGender, value.var = 'participated')
  tempTab2 &lt;- dcast(tx, formula = ExamenYear ~ StudentGender, value.var = 'passed')
  
  as.data.frame(cbind(ExamenYear = tempTab1[,1],
                  Female_Participated = tempTab1[,2],
                  Female_Passed       = tempTab2[,2],
                  Male_Participated    = tempTab1[,3],
                  Male_Passed          = tempTab2[,3]
                  ))
  </code></pre>
  
  <p><strong>Is it possible to have have two "value variables" in a cast function ?</strong> </p>