2014-10-29 78 views
4

有沒有在R中產生這個圖像的包? The image有沒有在R中產生這個圖像的任何包和函數?

我想看到一些變量的相關性,分佈和散點圖。

+1

老實說,而這無疑是一個編程問題和排序的屬於這裏,你可能不得不通過在http://stats.stackexchange.com/統計門戶網站更好的運氣。 – 2014-10-29 05:34:52

+2

可能你想看看ggplot2,GGally。他們可能不會給你確切的答案。但非常接近。 – KFB 2014-10-29 05:35:36

+0

我喜歡它,GGally很棒。 – parvij 2014-10-29 06:28:40

回答

6

你可以使用

library(psych) 
pairs.panels(iris[,-5], hist.col="white", scale=TRUE) 

enter image description here

5

此圖可完全從?pairs下給出的例子來構建。

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, ...) 
} 

panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...) { 
    usr <- par("usr"); on.exit(par(usr)) 
    par(usr = c(0, 1, 0, 1)) 
    r <- abs(cor(x, y)) 
    txt <- format(c(r, 0.123456789), digits = digits)[1] 
    txt <- paste0(prefix, txt) 
    if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt) 
    text(0.5, 0.5, txt, cex = cex.cor * r) 
} 

pairs(iris, lower.panel=panel.smooth, upper.panel=panel.cor, 
     diag.panel=panel.hist) 

enter image description here

相關問題