0

I have created this pairs plot of a 10X10 data frame. I am interested in extracting only the last row, as it shows the covariates (on x axis) against the response parameter of interest (on y axis) for each covariate. I have used basic R pairs plot, but if a solution exist for ggpairs I can easily modify the code below.

pairs.panels(data, smooth = TRUE, scale = FALSE, density = TRUE, ellipses = FALSE)

The pairs plot looks like this: enter image description here

oguz ismail
  • 1
  • 16
  • 47
  • 69

2 Answers2

2

I wrote a package called psre (you can install it from CRAN) and it has a function called lsa() (which stands for Linear Scatterplot Array). The function does what you want. Here's how it works:

library(psre)
data(wvs)
lsa(sacsecval ~ resemaval + moral + 
                pct_univ_degree + pct_female + 
                pct_low_income, 
    xlabels = c("Emancipative Vals", "Moral Perm", 
                "% Univ Degree", "% Female", "% Low Income"), 
    ylab = "Secular Values", 
    data=wvs)

enter image description here

DaveArmstrong
  • 18,377
  • 2
  • 13
  • 25
2

Use the arg horInd, which is documented in ?graphics::pairs.

library(psych)

pairs.panels(attitude, horInd = 7)

enter image description here

The original output:

pairs.panels(attitude)

enter image description here

Darren Tsai
  • 32,117
  • 5
  • 21
  • 51