| backtransformAffine {aroma.light} | R Documentation |
Reverse affine transformation.
## S3 method for class 'matrix' backtransformAffine(X, a=NULL, b=NULL, project=FALSE, ...)
X |
An NxK |
a |
A scalar, |
b |
A scalar, |
project |
returned (K values per data point are returned).
If |
... |
Not used. |
The "(X-a)/b" backtransformed NxK matrix is returned.
If project is TRUE, an Nx1 matrix is returned, because
all columns are identical anyway.
Missing values remain missing values. If projected, data points that contain missing values are projected without these.
X <- matrix(1:8, nrow=4, ncol=2) X[2,2] <- NA print(X) # Returns a 4x2 matrix print(backtransformAffine(X, a=c(1,5))) # Returns a 4x2 matrix print(backtransformAffine(X, b=c(1,1/2))) # Returns a 4x2 matrix print(backtransformAffine(X, a=matrix(1:4,ncol=1))) # Returns a 4x2 matrix print(backtransformAffine(X, a=matrix(1:3,ncol=1))) # Returns a 4x2 matrix print(backtransformAffine(X, a=matrix(1:2,ncol=1), b=c(1,2))) # Returns a 4x1 matrix print(backtransformAffine(X, b=c(1,1/2), project=TRUE)) # If the columns of X are identical, and a identity # backtransformation is applied and projected, the # same matrix is returned. X <- matrix(1:4, nrow=4, ncol=3) Y <- backtransformAffine(X, b=c(1,1,1), project=TRUE) print(X) print(Y) stopifnot(sum(X[,1]-Y) <= .Machine$double.eps) # If the columns of X are identical, and a identity # backtransformation is applied and projected, the # same matrix is returned. X <- matrix(1:4, nrow=4, ncol=3) X[,2] <- X[,2]*2; X[,3] <- X[,3]*3 print(X) Y <- backtransformAffine(X, b=c(1,2,3)) print(Y) Y <- backtransformAffine(X, b=c(1,2,3), project=TRUE) print(Y) stopifnot(sum(X[,1]-Y) <= .Machine$double.eps)