Skip to content

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:

  
    
#
On Fri, 13 Jul 2007, David Barron wrote:

            
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.