Hi all,

I am looking to obtain one column/row of a correlation matrix from my data 
using the function ggcorr() from library(GGally). 

As an example, using the mtcars dataset, I have the following code that can 
reproduce one row/column:

df <- cor(x = mtcars$mpg, y = mtcars[2:11], use = “everything”)
library(corrplot)
corrplot(df, tl.srt = 45, method = “color”, addCoef.col = “black”, cl.cex = 
0.56)

This shows all the correlations between mpg. However using ggcorr() and 
plotting it:

ggcorr(mtcars, method = c(“everything”), label = TRUE, label_size = 2, 
label_round = 4)

It shows a much nice and prettier looking correlation plot but does it for all 
variables. 

I have tried putting mtcars$mpg and mtcars[,1] to only return the one row, but 
neither seem to work. 

Any ideas on how to do it using ggcorr()?

Thanks,
Sam

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to