[R] mysterious extra spaces appearing in expression paste

David Winsemius dwinsemius at comcast.net
Tue Feb 2 20:17:21 CET 2010


On Feb 2, 2010, at 2:13 PM, George Locke wrote:

> Hi,
>
> i'm trying to put a legend on some figures and they're coming out a
> bit wonky.  here's an example:
>
> a <- c(1:10)
> par(mfrow=c(2,1))
> plot(a,type="s",lwd=3)
> leg <- c(expression(paste("data1 (",rho,"=1)")),
> expression(paste("data2 (",rho,"=0.0)")))
> legend("bottomright",legend=leg,col=c(1,2),lwd=3)
> plot(a,type="s",lwd=3)
> leg <- c(expression(paste("data1 \n(",rho,"=1)")),
> expression(paste("data2 \n(",rho,"=0.0)")))
> legend("bottomright",legend=leg,col=c(1,2),lwd=3, y.intersp =  
> 2.0,adj=c(0,1.5))
>
> the problem is that lots of extra space appears between the open
> parenthesis and the rho.

You need to use sep=""

>
> what can be done?  (i'm running  version 2.10.1 (2009-12-14) on  
> fedora 12)
>
> Thanks!
>
> George Locke
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list