Skip to content
Prev 261741 / 398502 Next

plotmath: paste string and expression [from a vector of expressions]

On Jun 2, 2011, at 5:07 PM, Marius Hofert wrote:

            
I do not have experience with that package but my guess is that the  
plot.mle2 (or whatever its name might be... )  function does something  
different. class(mlp) returns "profile.mle2". Looking at the  
documentation you see that it is using S4 methods and using Methods()  
one sees that there is a 'plot' method for 'profile.mle2' objects.  
That's about as far as I go.

<whine-mode on>
  Navigating S4 methods is an arcane art into which I have not  
initiated myself. Unlike S3 methods where you just type the function  
name and it's easy to figure out what the names will be, there are  
several levels of specification and the help pages for "Methods' ....  
are not, ... "helpful" to one who approaches it without more  
experience than I have. The help page regarding acceptable expressions  
to pass to "main" arguments is not particularly helpful, either. I  
would advise asking the package author or maintainer.

Before anyone berates me for insufficient effort at self-learning, I  
swear that my copy of Chambers (2008) arrived this week. I do think it  
would be "helpful" to have a worked example near the top of examples  
on help(Methods) that shows HOW_TO get at the functional machinery for  
a plot method when one knows the class of an object.

After some further experimentation I have a theory that the 'main'  
argument will not accept a language object but that one can coerce to  
an expression object and succeed. (Didn't I go through this once  
before? Maybe this was what Hadley was trying to teach me about a  
month ago.)
<whine-mode off>

# -----Answer

plot(mlp, main=as.expression(bquote(bold(Foo~.(vars[[2]])  )) ) )

# --- back your regularly scheduled programming -------