[Rd] plotmath indices: suggested addition to help file

Peter Ehlers ehlers at ucalgary.ca
Fri Jan 21 15:17:20 CET 2011


On 2011-01-21 02:27, Martin Maechler wrote:
> Thank you, Claudia,
>
>>>>>> "CB" == Claudia Beleites<cbeleites at units.it>
>>>>>>      on Thu, 20 Jan 2011 14:05:41 +0100 writes:
>
>      CB>  Dear all, I just stumbled over the fact that subsetting
>      CB>  by square bracket will only output the first given
>      CB>  index. I guess the rest is thrown away by the CADDR in
>      CB>  RenderSub (plotmath.c l. 1399).  Maybe changing this
>      CB>  could be considered as "low-priority desired" (would be
>      CB>  nice if the output works for ?
>
> I agree this is a  ``missing feature'' and well worth wish list item.
>
>      CB>  However, I suggest to announce the fact that only the
>      CB>  first parameter is printed in plotmath.Rd.
>
>      CB>  E.g. in the table l. 72
>      CB>   \code{x[i]} \tab x subscript i;  escape further indices (\code{x ["i, j"]})\cr
>
> How would get the equivalent of  LaTeX  x_{i_1, j_2}  ?
> Not by making it a string (that's not  escape, I'd say),
> but by something like
>
>      plot(0, axes=FALSE, main= expression(paste(x[i[1]],{}[j[2]])))
>
> which works +-
> but of course is unnecessarily ugly, compared to the desired
>
>      plot(0, axes=FALSE, main= expression(      x[i[1], j[2]]))
>

I don't know if I've ever disagreed with Martin's advice but,
unless I'm missing something, Claudia wants something done about
the second index in x[i, j] while Martin is talking about the
case of cascading subscripts in 'x_sub_i_sub_1' (as shown in his
LaTeX expression).

Both situations are nicely handled with the 'list()' and '[]'
constructs in plotmath:

   plot(0, axes=FALSE, main= expression( x[ list( i[1], j[2] ) ] ) )

To handle Claudia's wish, it might be desirable to have plotmath.c
automatically recognize such cases but I would consider that to
be (as Claudia says) in the 'nice if' category. Claudia's suggestion
for the help page could be handled by adding another example. Then
again, plotmath (not surprisingly) is like LaTeX in that, the more
you use it, the more you become familiar with the special constructs
needed to get the output you want. I still find myself scurrying to
?plotmath and scanning the Syntax/Meaning table quite frequently.

Peter Ehlers

> Martin
>
>      CB>  Claudia
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list