Skip to content
Prev 6092 / 7420 Next

correlation plot in color

Ok. As for your problem with the categorical variable Treat, you just exclude it when calling the chart.Correlation function. Assuming that Treat is the fifth column in your data set, then:


chart.Correlation(Libro1[,1:4], histogram = F, pch = 19)


should do. However, I do not know how to make the chart.Correlation function to use another variable to map colour.


Salvador


Salvador S?NCHEZ-COL?N
An independent consultant
Statistics, GIS, RS






En Dom, 22 Marzo, 2020 en 12:56, Manuel Esteban Lucas Borja <ManuelEsteban.Lucas at uclm.es> escribi?:
?

Para: Salvador SANCHEZ COLON
Cc: bfalevlist at gmail.com; r-sig-ecology at r-project.org

Gracias Salvador, 
?
I tried this but the question is that I would like to obtain a composite plot containing all the correlation, histograms and point colours depending on the treat variable. 
Thanks for your time
All the best
M

[Logotipo UCLM<http://www.uclm.es/comun/imgweb/firma_correo/uclm.jpg>]<http://www.uclm.es/>
Manuel Esteban Lucas Borja
Profesor Contratado Doctor Interino / Assistant Professor
Coordinador de Relaciones Internacionales del Campus de Albacete/Coordinator for International Relations on Albacete Campus
?
Universidad de Castilla-La Mancha
E.T.S. Ingenieros Agr?nomos y de Montes / Higher Technical School of Agricultural and Forestry Engineering | Campus Universitario s/n | C.P. 02071 Albacete
Tfno: 967 599 200<tel:+34:967599200>?|?Ext: 2818<tel:+34:2818> |?ManuelEsteban.Lucas at uclm.es<mailto:ManuelEsteban.Lucas at uclm.es> 
http://blog.uclm.es/manuelestebanlucas/?|?Mensaje Instant?neo<sip:ManuelEsteban.Lucas at uclm.es> 
???[ORCID<http://www.uclm.es/comun/imgweb/firma_correo/orcid.jpg>]<http://orcid.org/0000-0001-6270-8408>? ?[Google Scholar<http://www.uclm.es/comun/imgweb/firma_correo/googlescholar.png>]<https://scholar.google.es/citations?user=VjvdjnQAAAAJ&amp;hl=es> 
[In<http://www.uclm.es/comun/imgweb/firma_correo/in.jpg>]<https://www.linkedin.com/company/uclm>? [Twitter<http://www.uclm.es/comun/imgweb/firma_correo/twitter.jpg>]<https://twitter.com/#!/uclm_es>? [Facebook<http://www.uclm.es/comun/imgweb/firma_correo/facebook.jpg>]<https://www.facebook.com/uclm.es>? [YouTube<http://www.uclm.es/comun/imgweb/firma_correo/youtube.png>]<https://www.youtube.com/user/UCLMvideos>
?
Por favor, no imprima este documento si no es estrictamente necesario. Cuidar el medioambiente es responsabilidad de todos.
Este mensaje de correo electr?nico puede contener informaci?n confidencial de la UCLM, siendo para uso exclusivo del destinatario.
Si usted lo ha recibido por error y no es el destinatario del mensaje, le rogamos que no difunda su contenido y lo comunique al remitente. 
?
Please do not print this document unless absolutely necessary. Environmental protection is in our hands.
This e-mail may contain confidential information of the UCLM and is exclusively intended for the addressee.
If you have received it by mistake and are not the intended recipient, do not send the contents and please notify the sender. 
?


De: Salvador SANCHEZ COLON <salvadorsanchezcolon at prodigy.net.mx> 
Enviado el: domingo, 22 de marzo de 2020 19:25
Para: Manuel Esteban Lucas Borja <ManuelEsteban.Lucas at uclm.es>
CC: bfalevlist at gmail.com; r-sig-ecology at r-project.org
Asunto: Re: [R-sig-eco] correlation plot in color
?
Hola Manuel:
?
As you have loaded the ggplot2 package, one simple way to do the correlation plots (one at the time though) is, for example for your pair of variables EMF and your first MSD axis:
?ggplot(data = Libro) + ??geom_point(mapping = aes(x = EMF, y = MSD1, color = Treat)) 
I hope this helps.?

?

Salvador

An independent consultant

Biostatistics, GIS, RS
En Dom, 22 Marzo, 2020 en 10:34, Manuel Esteban Lucas Borja <ManuelEsteban.Lucas at uclm.es<mailto:ManuelEsteban.Lucas at uclm.es>> escribi?:

?


Para: Bede-Fazekas ?kos; r-sig-ecology at r-project.org<mailto:r-sig-ecology at r-project.org>
Dear ?kos Bede-Fazekas
Sorry for the missed information. Please see the packages I used: 

library(readxl)
library(dplyr)
library(ggplot2)
library(GGally)
library(Hmisc)
library(corrplot)
library(PerformanceAnalytics)

Then I import the attached dataset (Libro1) containing 5 variables: EMF, bio, MSD1, MSD2 (all of them numerical) and Treat (categorical).
Then I wrote:

            
And got the error: 

Error in pairs.default(x, gap = 0, lower.panel = panel.smooth, upper.panel = panel.cor) : 
non-numeric argument to 'pairs' 

And I would like to obtain the plot you can see on the doc file, where correlation points are divided by a category (red, gren and blue)

Thanks a lot for your help
Manuel 



-----Mensaje original-----
De: R-sig-ecology <r-sig-ecology-bounces at r-project.org<mailto:r-sig-ecology-bounces at r-project.org>> En nombre de Bede-Fazekas ?kos
Enviado el: domingo, 22 de marzo de 2020 16:57
Para: r-sig-ecology at r-project.org<mailto:r-sig-ecology at r-project.org>
Asunto: Re: [R-sig-eco] correlation plot in color

Dear Manuel,

since neither a reproducible example or your dataset are provided, nor the details of your problem (results of sessionInfo(); the package of corrMatOrder(); the error message you got) are known by us, it is a bit hard to help you. Anyway, I guess, that your data is not in categorical
(factor) but in ordinal (ordered) scale. If you convert your ordoered data to numeric with as.numeric(), then Spearman and Kendall rank correlations can be used.

HTH,
?kos Bede-Fazekas
Hungarian Academy of Sciences


2020.03.22. 14:29 keltez?ssel, Manuel Esteban Lucas Borja ?rta:
_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org<mailto:R-sig-ecology at r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org<mailto:R-sig-ecology at r-project.org> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology