I can't believe I'm having such a hard time with this and I haven't been able to find out how to solve this... lab <- expression( paste( hat(v), as.character(round(y.hat,2)), ",", hat(sigma)^2, as.character(sigma.hat)) ) text( x=pt$x+2, y=pt$y,labels=lab ) ## the text should be \hat{y} = <value of y.hat>, \hat{\sigma}^2 == <value of sigma.hat> and R keeps displaying the actual text of the non-expressions... I must be a chowderhead, but I need a little guidance, please... Thanks, Jeff. -- Forest Informatics, Inc. PO Box 1421 Corvallis, Oregon 97339-1421
Try bquote: y.hat <- sigma.hat <- 1.1 plot(1) lab <- bquote(hat(y) == .(y.hat) * "," ~ hat(sigma)^2 == .(sigma.hat)) text(1, 1, lab, pos = 4) On 8/23/06, Jeff D. Hamann <jeff.hamann at forestinformatics.com> wrote:> I can't believe I'm having such a hard time with this and I haven't been > able to find out how to solve this... > > lab <- expression( paste( hat(v), > as.character(round(y.hat,2)), ",", > hat(sigma)^2, as.character(sigma.hat)) ) > text( x=pt$x+2, y=pt$y,labels=lab ) > > ## the text should be \hat{y} = <value of y.hat>, \hat{\sigma}^2 == <value > of sigma.hat> > > and R keeps displaying the actual text of the non-expressions... > > I must be a chowderhead, but I need a little guidance, please... > > Thanks, > Jeff. > > > -- > Forest Informatics, Inc. > PO Box 1421 > Corvallis, Oregon 97339-1421 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Please visit the R site http://www.r-project.org/ and search the mailing list for "paste expression" We discussed the topic recently. The "trick" is that you don't paste expressions, you make an expression containing paste. Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Jeff D. Hamann Sent: Wednesday, August 23, 2006 11:02 PM To: r-help at stat.math.ethz.ch Subject: [R] help with pasting + expressions? I can't believe I'm having such a hard time with this and I haven't been able to find out how to solve this... lab <- expression( paste( hat(v), as.character(round(y.hat,2)), ",", hat(sigma)^2, as.character(sigma.hat)) ) text( x=pt$x+2, y=pt$y,labels=lab ) ## the text should be \hat{y} = <value of y.hat>, \hat{\sigma}^2 == <value of sigma.hat> and R keeps displaying the actual text of the non-expressions... I must be a chowderhead, but I need a little guidance, please... Thanks, Jeff. -- Forest Informatics, Inc. PO Box 1421 Corvallis, Oregon 97339-1421 ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.