apply() functions

apply() summarizes matrices over margins.

apply(x, 1, sum) # margin = 1 are the rows
## [1] 27 30 33 36 39 42 45 48
apply(x, 2, sum) # margin = 2 are the columns
## [1]  36 100 164

Often used in statistical methods (matrix algebra).