[R] Excluding data with apply

Christian Kamenik
Thu, 08 Jan 2009 10:52:34 -0000

Dear all,

'Apply' is a great thing for running functions on rows or columns of a
matrix:

X <- rnorm(20, mean = 0, sd = 1)
dim(X) <- c(5,4)
apply(X,2,sum)

Is there a way to use apply for excluding rows or columns from a matrix
to run functions on the remaining rows or columns? I know, I could do
this with a 'for' loop, but 'apply' would be much easier and
quicker,
and require less programming...

Cheers, Christian