Dear all,
I've got many responses to my initial question, which is stated below.
However, from those responses it has become clear that I need to
rephrase my problem. All responses dealt with subscripting the data
matrix before 'apply' is run on it. But this is not want I wanted to do.
you can use something like the following:
# your matrix
mat - matrix(rnorm(20), 5, 4)
# an indicator matrix specifying which columns
# you want to exclude each time
ind - matrix(sample(1:3, 18, TRUE), ncol = 3)
apply(ind, 1, function (i) mean(mat[, -i]))
where you may change mean() with
2 matches
Mail list logo