blockAvg.matrix: Average matrix

Description Usage Arguments Value Author(s) See Also Examples

Description

Average matrix.

Usage

1
2
## S3 method for class 'matrix'
blockAvg(X, idxs, FUN=rowMeans, W=NULL, ...)

Arguments

X

A numeric NxM matrix.

idxs

An integer KxJ matrix specifying an block indices map.

FUN

The function used to average over each block.

W

An optional numeric NxM matrix of weights.

...

Additional arguments passed to then FUN function.

Value

Returns a numeric matrix with colnames.

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

See Also

getBlockAverageMap().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
X <- matrix(rnorm(5*20), ncol=5)

for (h in c(1,2,3,4)) {
  print(h)
  map <- getBlockAverageMap(nrow(X), h=h)
  print(map)
  Xh <- blockAvg(X, idxs=map)
  print(Xh)
}


h <- 4.5
print(h)
map <- getBlockAverageMap(nrow(X), h=h)
print(map)
Xh <- blockAvg(X, idxs=map)
print(Xh)

HenrikBengtsson/aroma.cn.eval documentation built on Dec. 9, 2019, 12:16 p.m.