Displaying 1 result from an estimated 1 matches for "aggrtable".
2010 Jun 01
2
Help on aggregate method
...ate method:
More specifically, I would like to calculate the mean of certain
values on a data frame,? grouped by various attributes, and then
create a new column in the data frame that will have the corresponding
mean for every row. I attach part of my code:
matchMean <- function(ind,dataTable,aggrTable)
{
index <- which((aggrTable[,1]==dataTable[["Attr1"]][ind]) &
(aggrTable[,2]==dataTable[["Attr2"]][ind]))
as.numeric(aggrTable[index,3])
}
avgDur <- aggregate(ap.dat[["Dur"]], by = list(ap.dat[["Attr1"]],
ap.dat[["Attr2"]]), FUN=...