`tapply()` to return data frame
问题 I have a dataset with a datetime (POSIXct), a "node" (factor) and and a "c" (numeric) columns, for example: date node c 1 2011-08-14 10:30:00 2 0.051236000 2 2011-08-14 10:30:00 2 0.081230000 3 2011-08-14 10:31:00 1 0.000000000 4 2011-08-14 10:31:00 4 0.001356337 5 2011-08-14 10:31:00 3 0.001356337 6 2011-08-14 10:32:00 2 0.000000000 I need to take the mean of column "c" for all pairs of "date" and "node", so I did this: tapply(data$c, list(data$node, data$date), mean) The result I obtain is