[R] Standardization Range

Stéphane Dray dray at biomserv.univ-lyon1.fr
Wed Mar 28 11:15:54 CEST 2007


Hi sergio,
Sergio Della Franca wrote:
> 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?
>
>   
As you do ... but don't use var which is the name of the function to 
compute variance.

Try something like :

 > stdrange <- function(x) {(x-min(x))/(max(x)-min(x))}
 > var=1:10 # not a good idea, just for fun
 > stdrange(var)
 [1] 0.0000000 0.1111111 0.2222222 0.3333333 0.4444444 0.5555556 0.6666667
 [8] 0.7777778 0.8888889 1.0000000

> 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.
>
>
>   


-- 
Stéphane DRAY (dray at biomserv.univ-lyon1.fr )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57       Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/



More information about the R-help mailing list