Question

I have a matrix composed by floating point numbers. I have checked and there are no missing values.

Recently, I have changed the column header from (e.g.):

2670

to

COLUMN-HEADER-A-2670

I am running the code provided by Nearest Template Prediction algorithm, that I cannot change.

I found that the error is probably located when computing mean over the column axis, for each row of the matrix, i.e.

exp.mean <- apply(exp.dataset,1,mean,na.rm=T)

The mean for all rows is forced to NA and the R console tells me

Browse[2]> exp.mean <- apply(exp.dataset,1,mean,na.rm=T)
There were 50 or more warnings (use warnings() to see the first 50)
1: In mean.default(newX[, i], ...) :
  argument is not numeric or logical: returning NA

I think it is related with header type, but I cannot find anything that explains it. The algorithm worked with the previous column notation.

Was it helpful?

Solution

The answer is that in 3.1.0 read.table() returns a character vector instead of number vector if representing the table as a double matrix may lose accuracy.

From here:

type.convert() (and hence by default read.table()) returns a character vector or factor when representing a numeric input as a double would lose accuracy. Similarly for complex inputs.

If a file contains numeric data with unrepresentable numbers of decimal places that are intended to be read as numeric, specify colClasses in read.table() to be "numeric".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top