Calculate mean of multiple rows using grouping variables
<p>I am trying to calculate an overall mean of multiple classes. Currently the database is in long format. I tried selecting first ID number (group variable 1), then a dummy variable (stem=1) classes that I am interested in (grouping variable 2), and then calculating one GPA mean (i.e., stem GPA mean) for the grades received in interested classes (stem=1). </p>

<p>I have an attached an example of the database below. Overall,, I am trying figure out how to calculate stem GPA for each student.  </p>

<p><a href="http://i.stack.imgur.com/RlTxc.jpg" rel="nofollow">See example here</a></p>

<p>I have tried using library(psych), describeBy(data, dataset$id, dataset$stem), but to no avail. Any suggestions?</p>