On 2010-07-03 0:05, Godfrey van der Linden wrote:
G'day, All.
I have been trying to trackdown a problem in my R analysis script. I perform a
scale() operation on a matrix then do further work.
Is there any way of inverting the scale() such that
sX<- scale(X)
Xprime<- inv.scale(x); # does inv.scale exist?
resulting in Xprime_{ij} == X_{ij} where Xprime_{ij} \in R
There must be some way of doing it but I'm such a newb that I haven't been able
to find it.
Thanks
Godfrey
If your sX hasn't lost the "scaled:center" and
"scaled:scale" attributes that it got from the
scale() operation, then you can just reverse
the scaling procedure using those. Multiply
columns by the "scale" attribute, then add the
"center" attribute. Something like:
MN <- attr(sx, "scaled:center")
SD <- attr(sx, "scaled:scale")
Xprime <- t(apply(sx, 1, function(x){x * SD + MN}))
If the attributes have been lost by your further
work, then I'm afraid you're out of luck.
-Peter Ehlers
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.