Skip to content
Prev 275014 / 398506 Next

Aggregating data help

Hi:

Here's a way using the reshape2 package.

library('reshape2')
rsub <- subset(rtest, concept %in% c('8.2.D', '8.3.A', '8.3.B'))
# want year ahead of concept in the variable list
rsub <- rsub[, c(1:4, 9, 5:8)]

cast(rsub, id + test + subject + grade + year ~ concept, value_var = 'per_corr')
# Using per_corr as value column.  Use the value argument to cast to
override this choice
#   id test subject grade year 8.2.D 8.3.A 8.3.B
# 1  1   83 Mathema     8 2011   100    50   100
# 2  2   83 Mathema     8 2011   100   100    50

HTH,
Dennis
On Thu, Oct 20, 2011 at 11:55 AM, James Holland <holland.aggie at gmail.com> wrote: