Thomas Maier
2010-Aug-31 15:34 UTC
[R] Greek letters and variable values in lattice plot annotation
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. 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! [[alternative HTML version deleted]]
David Winsemius
2010-Aug-31 16:07 UTC
[R] Greek letters and variable values in lattice plot annotation
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