x <- c(1,2,3)
y <- t(c(4,5))
x %m+% y
mmapply(sum, x, x, t(x))
m <- matrix(3*(1:12)^2, 3, 4)
cm <- t(colMeans(m))
m %m-% cm
summaries <- list(Max = max, Min = min, avg = mean)
data <- list(a = 1:5, b = 2:3, c = 20:12)
formatStrings <- array(c('%.1f', '%.3f'), c(1,1,2))
mmapply(function(f, d, s) sprintf(s, f(d)), summaries, t(data), formatStrings)
Run the code above in your browser using DataLab