George Locke
2010-Feb-02 19:13 UTC
[R] mysterious extra spaces appearing in expression paste
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. what can be done? (i'm running version 2.10.1 (2009-12-14) on fedora 12) Thanks! George Locke
try putting sep="" in your paste method ----- Anna Lippel -- View this message in context: http://n4.nabble.com/mysterious-extra-spaces-appearing-in-expression-paste-tp1460261p1460264.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2010-Feb-02 19:17 UTC
[R] mysterious extra spaces appearing in expression paste
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