2016-05-01 50 views
1

功能我想繪製R中的相關性矩陣與主對角線直方圖使用:直方圖上主對角線對R中

pairs(credit[,-(4:5)], diag.panel=panel.hist) 

,但我得到

object 'panel.hist' not found 

有什麼不對?

+0

HTTP引用它之前定義環境中的panel.hist功能://meta.stackexchange .com/questions/156800/ask-r-question-with-a-reproducible-example –

回答

2

您是否執行過代碼來定義panel.hist函數?由於每對文檔中(https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/pairs.html)的例子:

panel.hist <- function(x, ...) 
{ 
    usr <- par("usr"); on.exit(par(usr)) 
    par(usr = c(usr[1:2], 0, 1.5)) 
    h <- hist(x, plot = FALSE) 
    breaks <- h$breaks; nB <- length(breaks) 
    y <- h$counts; y <- y/max(y) 
    rect(breaks[-nB], 0, breaks[-1], y, col = "cyan", ...) 
} 

你需要運行這些代碼pairs()

+0

謝謝。最後,我想出了一個可能的解決方案。如果我使用:'install.packages(「BioStatR」) library(BioStatR) pairs(credit [, - (4:5)],diag.panel = panel.hist)'現在它起作用了。 – EanX