[R] Standardization Range

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Wed Mar 28 11:19:14 CEST 2007


you can still use scale() (as you have been told), look at the help 
page for more info, especially at the Arguments section, e.g.,


mat <- matrix(rnorm(100*10), 100, 10)

rng <- apply(mat, 2, range)
scale(mat, scale = rng[2, ] - rng[1, ])

or you could even use apply() directly, e.g.,

apply(mat, 2, function(x) (x - mean(x)) / diff(range(x)) )


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Sergio Della Franca" <sergio.della.franca at gmail.com>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, March 28, 2007 11:00 AM
Subject: [R] Standardization Range


> Dear R-Helpers,
>
>
> I want to perform a standardization of a variable with range method.
>
> i.e.:
>
> Standardization (range) ==> (var-min(var))/(max(var)-min(var))
>
>
> Do you konw how can i develop this?
>
> Thank you in advance.
>
>
> Sergio Della Franca
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list