0

I am reading in data features

data_features<-as.matrix(read.table("file.csv", header=TRUE,fill=TRUE));

Then converting to matrix and getting rid of Inf data using library "functional"

dd <-as.matrix(data_xls)
dd[apply(dd, 1, Compose(is.finite, all)),]

Then I am executing rcorr:

rcorr(dd)

And that results in:

Error in rcorr(dd) : NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning message:
In storage.mode(x) <- "double" : NAs introduced by coercion

Without the use of Compose from functional, I would have this problem when creating a matrix. Currently, I don't have it when creating the matrix but afterwards when executing rcorr.

tesgoe
  • 1,012
  • 3
  • 10
  • 19

2 Answers2

2

Normally it is because there are some cells in your data frame with NA, NaN or Inf values. You can remove such value by using predicate is.na(x), Page on is.nan(x) and is.infinity(x). enter link description here

1

here's a late answer: I had the same problem and it ended up being the format of my numbers that was not accepted by the function. I had 1'203 instead of 1203 for ex. and that caused the error. Converting to normal number format worked. hope this helps