The general idea is to sweep the function across. You have many options, one is apply():
apply()
R> set.seed(42) R> M <- matrix(rnorm(40),ncol=4) R> apply(M, 2, sd) [1] 0.835449 1.630584 1.156058 1.115269 R>
548k questions
547k answers
4 comments
86.3k users