Hi, I have a data.frame that I need to scale. I've been using the scale function and it works nicely. Some of the libraries I'm testing won't accept negative values for data, so I need to find a way to scale the data from 0 to 1 Any ideas? Thans!
library(reshape) ?rescaler I think something along the lines of rescaler(data.frame, type="range") should do what you want. --- On Fri, 10/16/09, Noah Silverman <noah at smartmediacorp.com> wrote:> From: Noah Silverman <noah at smartmediacorp.com> > Subject: [R] Different way of scaling data > To: "r help" <r-help at r-project.org> > Received: Friday, October 16, 2009, 1:41 PM > Hi, > > I have a data.frame that I need to scale. > > I've been using the scale function and it works nicely. > > Some of the libraries I'm testing won't accept negative > values for data, so I need to find a way to scale the data > from 0 to 1 > > Any ideas? > > Thans! > > ______________________________________________ > R-help at 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. >
Read the whole help page for scale, then try: Newx <- scale(x, min(x), max(x)-min(x) ) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Noah Silverman > Sent: Friday, October 16, 2009 11:42 AM > To: r help > Subject: [R] Different way of scaling data > > Hi, > > I have a data.frame that I need to scale. > > I've been using the scale function and it works nicely. > > Some of the libraries I'm testing won't accept negative values for > data, > so I need to find a way to scale the data from 0 to 1 > > Any ideas? > > Thans! > > ______________________________________________ > R-help at 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.