Description Usage Arguments Value Missing values Examples
Reverse affine transformation.
1 2 | ## 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.