Linear Scaling
This will scale the numeric vector x
linearly from an old scale between low
and high
to a new one between newlow
and newhigh
.
LinScale(x, low = NULL, high = NULL, newlow = 0, newhigh = 1)
x |
a numeric matrix(like object). |
low |
numeric. The minimum value of the scale, defaults to min(x).
This is calculated columnwise by default; defined |
high |
numeric. The maximum value of the scale, defaults to max(x). This is calculated columnwise by default; when a maxval is entered, it will be recycled. |
newlow |
numeric. The minimum value of the new scale, defaults to 0, resulting in a 0-1 scale for x. |
newhigh |
numeric. The maximum value of the scale, defaults to 1.
|
Hmm, hardly worth coding...
The centered and scaled matrix. The numeric centering and scalings used (if any) are returned as attributes "scaled:center
" and "scaled:scale
"
Andri Signorell <andri@signorell.net>
# transform the temperature from Celsius to Fahrenheit LinScale(d.pizza[1:20, "temperature"], 0, 100, -17.8, 37.8 ) # and the price from Dollar to Euro LinScale(d.pizza[1:20, "price"], 0, 1, 0, 0.76) # together LinScale(d.pizza[1:20, c("temperature", "price")], 0, c(100, 1), c(-17.8, 0), c(37.8, 0.76) ) ## Not run: par(mfrow=c(3,1), mar=c(0,5,0,3), oma=c(5,0,5,0)) plot(LinScale(d.frm[,1]), ylim=c(-2,2), xaxt="n", ylab="LinScale") plot(RobScale(d.frm[,1]), ylim=c(-2,2), xaxt="n", ylab="RobScale") plot(scale(d.frm[,1]), ylim=c(-2,2), ylab="scale") title("Compare scales", outer = TRUE) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.