2012-06-27 43 views
1

我想通過從csv文件讀取數據來繪製矩陣的熱圖。 下面是代碼的外觀:使用R的熱圖

lda <- read.csv('topic_word_matrix.data',sep=",") 
row.names(lda) <- lda$topics 
lda <- lda[,2:ncol(lda)] 
lda_matrix <- data.matrix(lda) 
lda_heatmap <- heatmap(lda_matrix, Rowv=NA, Colv=NA,col = cm.colors(256), scale="column", margins=c(5,10)) 

我的輸入文件如下所示:

topics,jockin,limited,raining,magnetic,reallamarodom 
topic9,0.0,0.0,0.00671140939597,0.0022271714922,0.00234192037471 
topic2,0.1,0.0,0.02671140939597,0.0022271714922,0.00234192037471 

我得到一個情節,無任何顏色和下面的警告消息:

Warning messages: 
1: In min(x) : no non-missing arguments to min; returning Inf 
2: In max(x) : no non-missing arguments to max; returning -Inf 

有沒有人有任何線索可能出錯?

+0

我跑你的代碼與所提供的數據。這會產生一個帶有顏色的圖表,並且會顯示零警告。我建議你的輸入數據有問題。 – Andrie

+0

我知道代碼工作正常,但我不知道我應該在輸入數據中檢查以停止此警告消息並獲取顏色圖。你知道是什麼原因導致這個問題?它是一個超過3000個條目的巨大文件。我到底應該檢查什麼? – tan

+0

具體而言,這裏是實際的文件[鏈接](http://dl.dropbox.com/u/39515687/topic_word_matrix.data),這將引發此警告 – tan

回答

2

來自參數'scale =「columns」'的錯誤結果。

你的列具有0的標準偏差,因此縮放(平均/ SD)失敗。 因此,要麼使用scale =「row」或scale =「none」,要麼想爲什麼要在列上縮放。

HTH