[R] tapply

crmontes at ncsu.edu crmontes at ncsu.edu
Tue Apr 10 00:14:15 CEST 2007


Hi,

I have a summary table for an experiment that looks like this

STUDY BLOCK  TREATMENT MEASURMENT RESPONSE
A      1       T-0       1         12
A      1       T-1       1         52
A      1       T-0       2         12
A      1       T-1       2         65

and so on...

there are 10 studies, 4 blocks, 10 treatemnts, 5 measurments for
the response value.

I want to produce a table that looks like this:

STUDY BLOCK TREATMENT MEAS.1 MEAS.2 MEAS.3
A       1     T-1      15     54     65
A       1     T-2      54     65     45
A       2     T-1      12     12     23
A       2     T-2      65     54     65

and so on...

with tapply(RESPONSE, list(TREATMENT, MEASUREMENT, BLOCK, STUDY), mean)

I get very close, however, I get the results as a list!

if instead I use

ftable(tapply(RESPONSE, list(TREATMENT, MEASUREMENT, BLOCK, STUDY), mean))

I get REALLY close, but the I get only one value for each class, however I
need to whole table, because at the end, what I really need is the
increment between MEASUREMENT (n) - Measurement (n-1) for each TREATMENT,
BLOCK, STUDY, to perform a ANOVA analysis over increment data.

Esentialy, I want to move away from running a pivot-table in ACCESS

Any thoughts?

Cristian Montes
North Carolina State University



More information about the R-help mailing list