0

Can any R expert help me with this?

I am trying to make a pairplot with a target variable using R

The python equivalent would be

pp = sns.pairplot(data=data,
                  x_vars=['age'],
                  y_vars=['weight', 'height', 'happiness'])

I have got a basic pair plot mocked up

data <- data.frame(soildatacleaned$pH, 
                   soildatacleaned$Al, 
                   soildatacleaned$As,
                   soildatacleaned$Ba,
                   soildatacleaned$Ca,
                   soildatacleaned$Cd,
                   soildatacleaned$Ce,
                   soildatacleaned$Co,
                   soildatacleaned$Cr,
                   soildatacleaned$Cu)


pairs(data)

I would like to make the target variable to be pH (soildatacleaned$pH) which I am comparing against data in other columns.

How would I expand this code?

Christopher
  • 427
  • 1
  • 8
  • 18
  • 1
    Does this help answer your question? https://stackoverflow.com/questions/54937502/r-pairs-plot-of-one-variable-with-the-rest-of-the-variables – cgvoller Dec 08 '21 at 13:14

1 Answers1

1

There is the function GGally::ggpairs

library(GGally)
ggpairs(data)
danlooo
  • 10,067
  • 2
  • 8
  • 22