[R] Using expression in Hmisc Key()

Michael Kubovy kubovy at virginia.edu
Thu Dec 6 10:12:27 CET 2007


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
http://pbil.univ-lyon1.fr/R/fichestd/tdr75.pdf

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

> Michael Kubovy <kubovy <at> virginia.edu> 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)))))
>> dev.off()
>
> Michael,
>
> I have submit a similar case last week to the Bug tracker. Maybe you  
> can raise
> that "enhancement request" to "defect"
>
> http://biostat.mc.vanderbilt.edu/trac/Hmisc/ticket/21
>
> 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:    http://www.people.virginia.edu/~mk9y/



More information about the R-help mailing list