[R] surprising behaviour of "bgroup": sets all in greek letters
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sun May 25 18:00:05 CEST 2003
Uwe Ligges wrote:
> Ulf Martin wrote:
>
>> Dear R user community
>>
>> I wanted to use "bgroup" for plotting a math formula with
>> a big "{" on the left, and nothing on the right.
>> i used
>>
>> text( 10, 10, pos=4, cex=1.8, expression(F(x) == bgroup("{", x,
>> "")), ...)
>>
>> on a 40 x 20 plot.
>> surprisingly,
>> bgroup sets "Phi(xi) = { xi" i.e. replaces alphabetic characters with
>> greek letters in the entire formula.
>>
>> I tried out other ending delimiters instead of "":
>> With " ", ":", ";", ",", R complains about an "invalid group delimiter",
>> With "." R produces greek letters again.
>>
>> Is this a bug, or am I missing something?
>> How could I possibly accomplish my original task?
>> The idea is to have something like
>>
>> 0 if x<0
>> F(x) = {
>> y otherwise
>>
>> in the end.
>>
>> Thanks in advance!
>> (and for the great tool anyway!)
>>
>> (I am not currently subscribed to the r-help list,
>> so I would be gratful if anybody could answer me directly too, thanks!)
>>
>> Bye
>
>
> Looks like a bug. I'll investigate further within the next couple of
> days (except anyone else comes up with the right idea before).
>
> Uwe Ligges
Yes, it is a bug.
I don't know whether I'm working only on the symptoms here, but the
following patch to .../src/main/plotmath.c should fix it. I'll file it
to R-Bugs at once.
Uwe Ligges
==========================
(diff'ed to R-1.7.0 patched (2003-05-25))
> diff -u ./plotmath.old ./r-patched/src/main/plotmath.c
--- ./plotmath.old 2003-05-25 17:47:23.000000000 +0200
+++ ./r-patched/src/main/plotmath.c 2003-05-25 17:49:38.000000000 +0200
@@ -2075,10 +2075,12 @@
delim2 = DelimCode(expr, CADDDR(expr));
bbox = RenderElement(CADDR(expr), 0);
dist = max(bboxHeight(bbox) - axisHeight, bboxDepth(bbox) +
axisHeight);
- bbox = RenderDelim(delim1, dist + extra, draw);
+ if (delim1 != '.')
+ bbox = RenderDelim(delim1, dist + extra, draw);
bbox = CombineBBoxes(bbox, RenderElement(CADDR(expr), draw));
bbox = RenderItalicCorr(bbox, draw);
- bbox = CombineBBoxes(bbox, RenderDelim(delim2, dist + extra, draw));
+ if (delim2 != '.')
+ bbox = CombineBBoxes(bbox, RenderDelim(delim2, dist +
extra, draw));
return bbox;
}
More information about the R-help
mailing list