[R] bquote inside a legend

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Oct 22 16:41:16 CEST 2004


Jean Eid wrote:

> I am trying to automate an outide of the plot region table that has the
> correlation coef. of the various variables in the plot. I am currently
> using bquote to get the greek/latex representation of $\rho$. what I want
> so what I have is the following
> 
>   rhoa <- cor(x, data1$No.Msa.Hosp)
>   rhon <- cor(x, data1$N.Not.Profit.msa)
>   rhop <- cor(x, data1$N.Profit.msa)
> 
>  temp <- bquote(list(rho["Not-profit]==.(rhon),rho["Profit"]==.(rhop),
>                 rho["All"]==.(rhoa)))
> 
> everything works fine but the problem is that the following legend call
>   legend(par("usr")[2]-a1,3*par("usr")[3]-b1,ex12, ncol=2)
> 
> does not respect the ncol argument. I am guessing it is respecting it but
> bquote is of dimension 1 i.e just a big string. Does anyone know of a way
> to break this into two columns


There is an example how to work with mathematical annotation in legend() 
in the Help Desk in R News 2/3.
Please specify easily reproducible examples (not examples with data we 
do not have) - according to the posting guide!

What you are probably going to do is something like:

plot(1:10)
rhoa <- 1
rhon <- 2
rhop <- 3
exprhoa <- substitute(rho["All"]==.(rhoa), list(rhoa = rhoa))
exprhon <- substitute(rho["Not-profit"]==.(rhon), list(rhon = rhon))
exprhop <- substitute(rho["Profit"]==.(rhop), list(rhop = rhop))
legend(2, 8, do.call("expression", list(exprhon, exprhop, exprhoa)), 
ncol = 2)


Uwe Ligges


> 
> Thank you
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list