2014-02-25 50 views
0

我在數據讀取功能Rcorr NA /南/ INF在國外函數調用

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

然後轉化爲矩陣和利用圖書館「功能性」擺脫天道酬勤數據

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

然後我正在執行rcorr:

rcorr(dd) 

這導致:

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 

沒有使用從功能撰寫,我會有這個問題時,創建一個矩陣 。目前,我在創建矩陣時沒有它,但是在執行rcorr之後再執行 。

+0

[This](http://stackoverflow.com/a/18624605/2886003)有幫助嗎? – Llopis

+0

[lm()NA/NaN/Inf error]的可能重複(http://stackoverflow.com/questions/8415778/lm-na-nan-inf-error) – Llopis

+0

不,我用過,但都沒有工作。 – tesgoe

回答

1

通常這是因爲您的數據框中有一些單元格具有NA,NaN或Inf值。 您可以使用謂詞is.na(x),頁面is.nan(x)is.infinity(x)刪除此值。 enter link description here

0

這裏有一個較晚的答案:我有同樣的問題,它最終成爲我的數字格式不被該函數接受。我只有1'203而不是1203。並導致錯誤。轉換爲正常的數字格式工作。希望這可以幫助

相關問題