Вот один вариант с aggregate
из base R
aggregate(m, list(row.names(m)), mean)
# Group.1 0 60 120 180
#1 0 4 4.5 4.75 5.5
#2 60 4 5.5 6.50 1.5
Или с использованием tapply
tapply(m, list(row.names(m)[row(m)], colnames(m)[col(m)]), FUN = mean)
Или с использованием by
do.call(rbind, by(m, row.names(m), FUN = colMeans))
# 0 60 120 180
#0 4 4.5 4.75 5.5
#60 4 5.5 6.50 1.5
Или с split
t(sapply(split(as.data.frame(m), row.names(m)), colMeans))
data
m <- structure(c(2, 6, 5, 3, 4, 4, 4, 8, 2, 4, 5, 6, 5, 7, 6, 1, 3,
10, 9, 6, 4, 3, 1, 2), .Dim = c(6L, 4L), .Dimnames = list(c("0",
"0", "0", "0", "60", "60"), c("0", "60", "120", "180")))