Learn R Programming

aroma.core (version 1.1.2)

colBinnedSmoothing.matrix: Binned smoothing of a matrix column by column

Description

Binned smoothing of a matrix column by column.

Usage

## S3 method for class 'matrix':
colBinnedSmoothing(Y, x=seq(length = ncol(Y)), w=NULL, from=min(x, na.rm = TRUE), to=max(x, na.rm = TRUE), by=NULL, length.out=length(x), xOut=NULL, na.rm=TRUE, FUN="median", ..., verbose=FALSE)

Arguments

Y
A numeric JxI matrix (or a vector of length J.)
x
A (optional) numeric vector specifying the positions of the J entries. The default is to assume uniformly distributed positions.
w
A optional numeric vector of prior weights for each of the J entries.
from,to
The center location of the first and the last bin.
by
The distance between the center locations of each bin.
length.out
The number of bins.
xOut
Prespecified center locations.
na.rm
If TRUE, missing values are excluded, otherwise not.
FUN
...
Not used.
verbose
See Verbose.

Value

  • Returns a numeric KxI matrix (or a vector of length K) where K is the total number of bins. Attribute 'xOut' specifies the center locations of each bin. The center locations are always uniformly distributed. Attribute 'binWidth' specifies the width of the bins. The width of the bins are always the same and identical to the distance between two adjacent bin centers.

See Also

*colKernelSmoothing().

Examples

Run this code
J <- 100
I <- 4
Y <- matrix(rnorm(I*J, sd=1/2), ncol=I)
# Introduce a gain in column 2 and 3
Y[30:50,2:3] <- Y[30:50,2:3] + 3
x <- 1:J

Ys3 <- colBinnedSmoothing(Y, x=x, from=2, by=3)
Ys5 <- colBinnedSmoothing(Y, x=x, from=3, by=5)

xlim <- range(x)
ylim <- c(-3,5)
layout(matrix(1:I, ncol=1))
par(mar=c(3,3,1,1)+0.1, pch=19)
for (ii in 1:I) {
  plot(NA, xlim=xlim, ylim=ylim)
  points(x, Y[,ii], col="#999999")
  xOut <- attr(Ys3, "xOut");
  lines(xOut, Ys3[,ii], col=2)
  points(xOut, Ys3[,ii], col=2)
  xOut <- attr(Ys5, "xOut");
  lines(xOut, Ys5[,ii], col=3)
  points(xOut, Ys5[,ii], col=3)
}

Run the code above in your browser using DataLab