[BioC] silly question about read.table

J.delasHeras at ed.ac.uk J.delasHeras at ed.ac.uk
Sun Feb 25 03:34:52 CET 2007


Quoting James Anderson <janderson_net at yahoo.com>:

> I am trying to use pamr (prediction analysis of microarray), which   
> uses nearest shrunken centroid classification. Now I want to load my  
>  data using read.table, then use pamr. the codes are as follows:
>
> Training = read.table("A.txt",header = FALSE)
> myData = list(x = Training,y = factor(TrainingLabel));
> mytrain = pamr.train(myData)
> It always complains "Error in x %*% Y : requires numeric   
> matrix/vector arguments"
>
> I think the main reason is variable Training read from read.table is  
>  an object, not just numeric matrix, I tried as.numeric(Training),  
> it  still has errors. I know if Training is created by something like
>
> Training = matrix(rnorm(1000*20),ncol=20)
> It will not complain, since by this way, Training is purely a   
> numeric matrix, not object. Does anybody know how to convert the   
> object read from read.table to a pure numeric matrix?
>
> Thanks,
>
> James

I am not familiar with pamr and the arguments it requires, but  
read.table will create a data frame object. As it has no header and  
(presumably) it only contains numbers in a table form, if you use  
'as.matrix(Training)' you'll convert Training from a data frame to a  
numeric matrix. If pamr expects a list where the first element is a  
matrix, it may work. Anyway, use 'as.matrix', not 'as.numeric'

I hope this helps a bit!

Jose

-- 
Dr. Jose I. de las Heras                      Email: J.delasHeras at ed.ac.uk
The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK



More information about the Bioconductor mailing list