Skip to content

File normalization

7 messages · cobbler_squad, Bert Gunter, Phil Spector +1 more

#
Dear all,

I have a file with 57 columns (671 time points in each column)

File looks like this:
1    0.279191   -1.203200e-02   -0.166772  6.12080e-02  0.196379 
4.591900e-02  0.293689  
2    0.267017   -1.150700e-02   -0.159463  5.85400e-02  0.187775 
4.392200e-02  0.280854  
3    0.053778   -2.322000e-03   -0.032103  1.18490e-02  0.037921 
8.867000e-03  0.056571  
4    0.035469   -1.531000e-03   -0.021166  7.79200e-03  0.024937 
5.843000e-03  0.037273  
5    0.040774   -1.761000e-03   -0.024342  8.96000e-03  0.028674 
6.726000e-03  0.042910  
6   -0.359709    1.547400e-02    0.214844 -7.87320e-02 -0.253034
-5.905100e-02 -0.378322 

I need to normalize it -- is it possible?

I looked into normalize columns of a matrix to have the median absolute
value in R, but I am not sure how to apply it in this case. Would very much
appreciate any input you could give me..

Thank you all in advance,

Cobbler
#
?scale

is specifically written for this. See also ?sweep

Bert Gunter
Genentech Nonclinical Biostatistics
 
 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Joris Meys
Sent: Tuesday, May 25, 2010 9:54 AM
To: cobbler_squad
Cc: r-help at r-project.org
Subject: Re: [R] File normalization

My code substracts the median absolute value. If you want to divide by it,
the code must be :
apply(some_dataset,2,function(
Thanks to Peter Langfelder for pointing out my mistake.
On Tue, May 25, 2010 at 6:24 PM, Joris Meys <jorismeys at gmail.com> wrote:

            

  
    
#
The scale function can use whatever vector you choose for
subtraction and division.  (It's basically a wrapper for
the sweep function.) For example, to subtract the 
median and divide by the median absolute deviation, use

scale(x,center=apply(x,2,median),scale=apply(x,2,mad))

Either the center= or scale= arguments can be omitted if
you only want to divide or subtract.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Tue, 25 May 2010, Joris Meys wrote: