我正在使用 R 函数 pairs() 并且我想针对一个特定的列创建散点图

I am using the R function pairs() and I want to create scatterplots against one specific column

我正在使用这些代码行在数据列的所有组合之间生成散点图: air 。有没有办法选择特定列的所有列组合?例如,如果我们有 5 列,我只需要 3d 列的散点图,例如:1-3、2-3、4-3、5-3。不是所有的组合。

pairs(air, labels = colnames(air), main = "Pairs matrix", pch = 21, 
bg = c("red", "green3", "blue", "yellow"),
upper.panel = NULL)

您可以使用 TeachingDemos 包中的 pairs2() 函数。例如:

library(TeachingDemos)
pairs2( airquality[3], airquality[,c(1,2,4,5) ], panel=panel.smooth)