[R] Greek letters and variable values in lattice plot annotation

David Winsemius dwinsemius at comcast.net
Tue Aug 31 18:07:49 CEST 2010


On Aug 31, 2010, at 11:34 AM, Thomas Maier wrote:

> I'd like to annotate a lattice plot, e.g. xyplot, with text  
> containing both
> Greek letters and variable values. In the base graphics plot command  
> this
> can be accomplished with e.g. main =
> substitute(paste(lambda,"=",var),list(var=var)), where var is a  
> variable
> that contains the value.

Try wrapping as.expression around that substitute argument. Both of  
these seem to deliver desired results.

 > var=5
 > xyplot(1~1, main = as.expression(bquote(lambda==.(var))))
 > xyplot(1~1, main =  
as.expression(substitute(paste(lambda,"=",var),list(var=var))))

> When I try to do this in xyplot, I get the error
> message "object 'lambda' not found". Any ideas on how to do this in  
> xyplot?
> Thanks for the help!
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list