1樓:黃春霖
同樣的圖也可以用GGally包裡的ggpair函式,能夠根據變數型別自動繪製散點圖箱形圖密度圖,也可以自動計算連續變數之間的相關係數
2樓:塵封
pairs
(iris
[,1:4])
結果如下:
你也可以去掉上三角部分,如:
pairs(iris[,1:4], upper.panel = NULL)
panel.cor <- function(x, ypar(usr = c(0, 1, 0, 1))
txt <- as.character(format(cor(x, y), digits = 2)) ### 求相關係數,並保留兩位小數
text(0.5, 0.5, txt, cex = 8 * abs(cor(x, y給定需新增相關係數的位置座標個字型大小(cex越大,則數字越大)
}pairs(iris[,1:4], upper.panel = panel.cor)
結果如下:
pairs的其他用法你可以用help看下,其實plot(iris[, 1:4], upper.panel = NULL)也有這個效果。
希望可以幫到你
C語言中不使用strcmp函式,怎麼用指標實現兩個字串的大小比較
這是微軟在UCRT中的實現,供參考 strcmp compare two strings,returning less than,equal to,or greater than Purpose STRCMP compares two strings and returns an integer t...
在R語言中怎麼在工作目錄下同時對多個檔案進行處理?
秋雨 pollutantmean function directory,pollutant,id 1 332 directory is a character vector of length 1indicating the location of the csv file id is an int...
c語言中的返回值究竟有什麼用?
已登出 舉個例子 讓題主去打醬油,大概會有三種結果 1 打到醬油了 2 醬油賣完了 3 錢不夠 我們就約定,打醬油函式返回的結果為三個不同的數,分別表示三種不同的結果。作為發號施令者 呼叫者 我不關心具體買醬油的細節 在哪個店買什麼牌子的醬油等 我只關心結果。所以結果就是約定好的,用來檢查 了解 函...