GGally/Pairs: Plot graphs at fixed column

Dear Community,

I am new here. I have a question regarding the correlation matrix/scatter plot/Matrix plot via pairs, ggally::ggpairs.

I have a data that contains 100 parameters and want to determine the correlation between them. eg.: Parameters 1 to 100 existing is column (import via excel) want to plot the graph between column 3 vs column [4:25] then column 3 vs column [26:40] and so on. How can i fix the column 3. (i mean how may i write a code so that the column 3 or any other column that want to see remain fixed and other column range bring into the code.
At the moment i did so:
GGally::ggpairs(data = data[3:12]) .
But am did not success that how may i write the code and got the image as mentioned below.

I hope, i have explain in the correct way. If not then please let me know.
I will be very thankfull if someone help me in this regard.

Many Thanks

I don't know if ggpairs is the best approach for just finding correlation of parameters.

I would try GGally::ggcorr(data). This should compare all columns against each other and will scale faster than GGally::ggpairs.

In the output of ggcorr, look in the row / column of the parameter that you are interested in.



Hi Barret,

Thanks for the idea. It is also a good approach to see the correlation between them.
But still my question is how can i fix one column/argument. As i said, i have 100 parameters. And it is not representable if i select all parameters together. Thats why i want to do in the following ways:
ggally::ggcorr(data[9:30]) and column 9 is my parameter that want to see.
GGally::ggcorr([31:42]) but how i bring column 9 in this code?

I hope you get my question.

Best Regards

So you're looking for a 1 x K plot matrix?

Using anscombe and pretending the first column is the Y variable I'd like to use against the next three columns. Does this work?

GGally::ggduo(anscombe, 2:4, 1, types = list(continuous = "cor"))

Yes, you are right. I want to do in that way. Thanks
Problem solved.......Many thanks barret

1 Like

Just one more question. is it possible to get these corr:vlaues in tabular format or at console area as we get summary(data). So that i will copy this corr values into excel.


This should get it for you.

anscombe %>% 
  pivot_longer(-x1) %>% 
  group_by(name) %>% 
  summarize(cor = cor(x1, value))
#> # A tibble: 7 x 2
#>   name     cor
#>   <chr>  <dbl>
#> 1 x2     1
#> 2 x3     1
#> 3 x4    -0.5
#> 4 y1     0.816
#> 5 y2     0.816
#> 6 y3     0.816
#> 7 y4    -0.314

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.