An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070713/b9511c5a/attachment.pl
standardization
3 messages · Amir_17, David Barron, Brian Ripley
Try having a look at the scale and sweep functions. David
On 13/07/07, Amir_17 <amirhendi at yahoo.com> wrote:
Hi
I have dataframe which contain 5 columns and 1000 records. I want standard each cell.
I want range each column between 0 and 1 . I think i must use loop?
could you help me?
---------------------------------
Moody friends. Drama queens. Your life? Nope! - their life, your story.
[[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.
================================= David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
On Fri, 13 Jul 2007, David Barron wrote:
Try having a look at the scale and sweep functions.
sweep applies to arrays, not data frames, and scale converts to a matrix.
For a data frame
df2 <- df1
df2[] <- lapply(df1, function(x) {r <- range(x, na.rm=TRUE);
(x-r[1])/diff(r)})
seems simple enough.
On 13/07/07, Amir_17 <amirhendi at yahoo.com> wrote:
Hi I have dataframe which contain 5 columns and 1000 records. I want standard each cell. I want range each column between 0 and 1 . I think i must use loop? could you help me?
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595