[BioC] silly question about read.table
Sean Davis
sdavis2 at mail.nih.gov
Sun Feb 25 03:05:37 CET 2007
James Anderson wrote:
> 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?
>
Hi, James.
If A.txt has any text columns in it, you will want to remove those
before reading it into R (or after it is in R). Then, you should be
able to do:
Training.matrix = as.matrix(Training)
Does that do what you want?
Sean
More information about the Bioconductor
mailing list