Re: [R] Normalizing Vector with Negative Numbers
You can use the scale function, just use the minimum instead of the mean and the range instead of the standard deviation. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Gundala Viswanath Sent: Sunday, September 26, 2010 6:23 PM To: r-h...@stat.math.ethz.ch Subject: [R] Normalizing Vector with Negative Numbers Dear expert, I have a series of number that looks like this x - c(-0.005282, 0.000314, 0.002851, -2.5059217162, -0.007545, -1.0317758496, 0.001598, -1.2981735068, 0.072411) How can I normalize it in R so that the new numbers is ranging from 0 to 1 ? - G.V. __ 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. __ 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.
[R] Normalizing Vector with Negative Numbers
Dear expert, I have a series of number that looks like this x - c(-0.005282, 0.000314, 0.002851, -2.5059217162, -0.007545, -1.0317758496, 0.001598, -1.2981735068, 0.072411) How can I normalize it in R so that the new numbers is ranging from 0 to 1 ? - G.V. __ 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.
Re: [R] Normalizing Vector with Negative Numbers
Is the what you want: x [1] -0.005282 0.000314 0.002851 -2.5059217162 -0.007545 -1.0317758496 0.001598 [8] -1.2981735068 0.072411 (x-min(x))/(max(x) - min(x)) [1] 0.969 0.971 0.972 0.000 0.968 0.5882632 0.972 0.4819563 1.000 On Sun, Sep 26, 2010 at 8:22 PM, Gundala Viswanath gunda...@gmail.com wrote: Dear expert, I have a series of number that looks like this x - c(-0.005282, 0.000314, 0.002851, -2.5059217162, -0.007545, -1.0317758496, 0.001598, -1.2981735068, 0.072411) How can I normalize it in R so that the new numbers is ranging from 0 to 1 ? - G.V. __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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.