Re: [R] Using expression in Hmisc Key()

From: Michael Kubovy <>
Date: Thu, 6 Dec 2007 04:12:27 -0500

Hi Dieter,

I actually solved *my* problem:

Key(x = 0.667, y = 0.833, lev = c(expression(italic(b)), expression(italic(c)), expression(italic(d))),

        other = list(title = expression(italic(v)), cex.title = 1))

I was able to figure this out only by looking at the code for Key(), because I hadn't come across the 'lev' argument in the documentation (in fact Key does not appear in the list of functions of Hmisc; I discovered its usefulness by consulting the examples for xYplot()). I would have expected this argument to be called 'labels' (see help(labels)), (or at least 'levels'):

function (x = NULL, y = NULL, lev = c("b", "c", "d"), cex = c(0.7, 0.7, 0.7), col = c(2, 4, 9), font = c(1, 1, 1), pch = c(1, 2, 16), other = NULL)


Note that the NULL setting of the parameter may be useful for programming, but it is not useful to anyone reading the code. How is one to proceed after having read help(NULL)?

At the same time, I have no grounds for complaining about the documentation for Key(): Frank Harrell is giving away his work. His examples are extensive, and his functions always work as advertised. Sometimes they also work as not advertised.

This is one of the cases where I wish there were a function that "exercised" all the arguments of a graphics function by visualizing the effect of changing two or three levels of each argument (one by one, of course). This might have the side effect of allowing authors to shorten documentation. I have in mind adding a method to each graphics function, and having the author specify the two or three instructive levels of each argument. See the exhaustive exploration by J.R. Lobry, A.B. Dufour & D. Chessel of the graphical parameters accessible by par(), at

On Dec 6, 2007, at 2:17 AM, Dieter Menne wrote:

> Michael Kubovy <kubovy <at>> writes:
>> Dear r-helpers,
>> How do I tell xYplot() and Key() that I want the labels in italic?
> ....
>> Key(x = 0.667, y = 0.833, other = list(title = expression(italic(v)),
>> cex.title = 1,
>> labels = c(expression(italic(b)), expression(italic(c)),
>> expression(italic(d)))))
> Michael,
> I have submit a similar case last week to the Bug tracker. Maybe you
> can raise
> that "enhancement request" to "defect"
> Dieter
> -----------
> The Key function generated by some plot commands should have a ...
> parameter.
> Otherwise, the ... in rlegend is useless, and it would be nice to be
> able to
> suppress the box, for example.
> Key = function (x = NULL, y = NULL, lev = c("No Fail", "Fail"), pch
> = c(16, 1))
> { .. part omitted
> rlegend(x, y, legend = lev, pch = pch, ...) invisible()
> }

Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766

WWW: mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 06 Dec 2007 - 09:14:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 06 Dec 2007 - 20:30:17 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.