[R] How to log-2 transform a matrix

(Ted Harding) Ted.Harding at manchester.ac.uk
Sat Nov 10 15:43:46 CET 2007


On 10-Nov-07 14:25:32, affy snp wrote:
> Dear list,
> I am wondering how to log-2 based transform a matrix
> with numeric values?
> I tried > CGHlog2<-log2(CGH) but got an error. Then I
> found for log2(x) in R, the x has to be a numeric or
> complex vector. Any method for a matrix?

Yes, simply the method you tried: log2(M) where M is
the matrix of numeric/complex datavalues.

log2() will work just as well on a dataframe whose
contents are numerical, as on a simple matrix:

M<-data.frame(A=c(1,2,3,4),B=c(2,3,4,5),C=c(3,4,5,6))
log2(M)
         A        B        C
1 0.000000 1.000000 1.584963
2 1.000000 1.584963 2.000000
3 1.584963 2.000000 2.321928
4 2.000000 2.321928 2.584963

>From the error message you quote below, it looks as
though you have made a mess of reading in, or constructing,
the dataframe (the output looks like a series of several
variables names, all concatenated together into one long
string value).

Hoping this helps!
Ted.

> Thanks a lot and have a good weekend!
> 
> Allen
> 
> 
>>Error in Math.data.frame(CGH) :
>   non-numeric variable in data frame:
> WM806SignalAWM1716SignalAWM1862SignalAWM1963SignalAWM1968SignalAWM1976Si
> gnalAWM3228SignalAWM3457SignalAWM3061SignalAWM3246SignalAWM3282SignalAWM
> 1931SignalAWM1026SignalAWM3670SignalAWM3702SignalAWM3482SignalAWM3311Sig
> nalAWM1960SignalAWM1720SignalAWM3215SignalAWM3451SignalAWM3130SignalAWM2
> 029SignalAWM3243NCI.A5SignalAWM1745SignalAWM3526SignalAWM3682SignalAWM36
> 23SignalAWM3450SignalAWM853.2SignalAWM1930SignalAWM3244NCI.BSignalAWM984
> SignalAWM3619SignalAWM3297SignalAWM451LuSignalAWM3077SignalAWM3381ASigna
> lAWM3627S
> ignalAWM3218SignalAWM3163SignalAWM3259SignalAWM3506SignalAWM3629SignalAW
> M3456SignalAWM1346SignalAWM1852SignalARCC13NSignalAJAPOV46NSignalAJAPOV7
> 5NSignalAS004285NSignalARCC50NSignalAJAPOV54NSignalAJAPOV92NSignalARCC56
> NSignalAS004288NSignalAS004295NSignalAS004292NSignalAJAPOV73NSignalAJAPO
> V52NSignalARCC53NSignalAS004289NSignalARCC25NSignalAS004294NSignalAS0042
> 75NSignalAJAPOV32NSignalACN37SignalACN16SignalAS004291NSignalACN17Signal
> ARCC129NS
> 
> ______________________________________________
> 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.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 10-Nov-07                                       Time: 14:43:42
------------------------------ XFMail ------------------------------



More information about the R-help mailing list