[R] mysterious extra spaces appearing in expression paste
George Locke
george.locke.physics at gmail.com
Fri Feb 5 18:41:01 CET 2010
Hey,
So I found workaround for what I'm now pretty sure is a bug.
the reason I'm sure it's a bug is that i found that I found that
linebreaks are handled in a wonky but regular way. There's a rule,
and it's a bad rule, ie a bug.
The wonky rule is as follows: text(x,y,expression(paste("thing1
\n","thing2"))) results in printing thing1 at the requested x/y with
the linebreak failing to cause a carriage return. That is, thing2
appears directly below the "1" in thing1.
******Bug report:
"\n" in paste doesn't make a carriage return, just a new line.
perhaps there's something like endl that I'm supposed to put in there
and I just don't know. I'll bring this to the attention of
r-bugs at r-project.org .
The workaround for my particular problem was to not use line breaks,
but instead break the legend up into four parts instead of 2, using
the fact that legend puts each legend=c() element on a new line.
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))
becomes
leg <- c("data1",expression(paste("(",rho,"=1)")), "data2",
expression(paste("(",rho,"=0.0)")))
legend("bottomright",legend=leg,col=c(1,1,2,1), lty=(1,0,1,0),
lwd=3)
note the lty to block the extra lines.
Regards,
George
On Tue, Feb 2, 2010 at 2:17 PM, anna <lippelanna24 at hotmail.com> wrote:
>
> 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.
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list