enrico.foscolo2 at libero.it
2009-Mar-25 10:22 UTC
[R] Including greek letters in a pairs() plot
Good Morning, I have a stupid problem about inclusion of greek letters in a plot built with function pairs(). First of all, I have a matrix with 3 columns and 1000 rows and I would like to use pairs() in order to plot points in the upper panel and to compute correlation in the lower panel. In the lower panel I would like to see the following text in each ij-plot: hat(rho)[i,j]=cor(x,y). Obviously, rho should be written in according to greek alphabet. This is my function: panel.cor <- function(x,y){ cor<-0 cor<-round(cor(x,y),4) text (0.5,0.5,cor,cex=2) } Thank You very much, Enrico Foscolo
Hi Enrico, see ?plotmath and the examples example(plotmath) there you will find all you need for your task. hth. enrico.foscolo2 at libero.it schrieb:> Good Morning, > > I have a stupid problem about inclusion of greek letters in a > plot built with function pairs(). > > First of all, I have a matrix with 3 columns > and 1000 rows and I would like to use pairs() in order to plot points in the > upper panel and to compute correlation in the lower panel. > > In the lower panel > I would like to see the following text in each ij-plot: hat(rho)[i,j]=cor(x,y). > Obviously, rho should be written in according to greek alphabet. > > This is my > function: > > panel.cor <- function(x,y){ > > cor<-0 > cor<-round(cor(x,y),4) > text > (0.5,0.5,cor,cex=2) > > } > > Thank You very much, > > Enrico Foscolo > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790
enrico.foscolo2 at libero.it wrote:> Good Morning, > > I have a stupid problem about inclusion of greek letters in a > plot built with function pairs(). > > First of all, I have a matrix with 3 columns > and 1000 rows and I would like to use pairs() in order to plot points in the > upper panel and to compute correlation in the lower panel. > > In the lower panel > I would like to see the following text in each ij-plot: hat(rho)[i,j]=cor(x,y). > Obviously, rho should be written in according to greek alphabet. > > This is my > function: > > panel.cor <- function(x,y){ > > cor<-0 > cor<-round(cor(x,y),4) > text > (0.5,0.5,cor,cex=2) > > }Example: panel.cor <- function(x,y){ cor <- round(cor(x,y),4) plot.window(0:1, 0:1) text(0.5, 0.5, substitute(hat(rho)[list(i,j)] == cor, list(cor=cor)), cex=1.2) } pairs(iris, lower.panel = panel.cor)> Thank You very much, > > Enrico Foscolo > > ______________________________________________ > R-help at r-project.org mailing list > 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.