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:
CodePudding user response:
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)
CodePudding user response:
Use the arg horInd
, which is documented in ?graphics::pairs
.
library(psych)
pairs.panels(attitude, horInd = 7)
The original output:
pairs.panels(attitude)