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 <[EMAIL PROTECTED]> 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,                  [EMAIL PROTECTED]
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

______________________________________________
R-help@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.

Reply via email to