Skip to content

matrix calculation

3 messages · Junyu Lee, R. Michael Weylandt, David Winsemius

#
Perhaps something like this (untested) -- it's going to depend on the
exact structure of your data so if this doesn't work, please use
dput() to send a plain text representation:

tapply(data, data$animal, function(d) d[, c("A01", "A02")] - d[d$time
== "d0", c("A01", "A02")] )

In short, take "data" split it into groups by "data$animal" and then
apply the function which consists of subtracting the "A01" and "A02"
columns by the row that has time == "d0"

Michael
On Fri, Dec 9, 2011 at 1:44 PM, Junyu Lee <junyu0813 at gmail.com> wrote:
#
On Dec 10, 2011, at 9:13 AM, R. Michael Weylandt wrote:

            
`tapply` is not documented to work on dataframes as a first argument.  
I think you may want to use aggregate or the split/lapply approach.