Thanks â thatâs the most helpful solution â itâs important for code to be neat too and that is fairly neat if unintuitive! I had tried bquote a bit, but hadnât figured it out properly.
Cheers! Paul From: Henrique Dallazuanna [via R] [mailto:ml-node+1289286-317759...@n4.nabble.com] Sent: 25 January 2010 12:21 To: Paul Chatfield Subject: Re: [R] Paste expression in graph title Try this: plot(x, y, main = bquote(R^2 == .(round(summary(lm(y ~ x))$r.squared, 3)))) On Mon, Jan 25, 2010 at 10:06 AM, Paul Chatfield <[hidden email] <http://n4.nabble.com/user/SendEmail.jtp?type=node&node=1289286&i=0> > wrote: > > This was my initial attempt at creating a title on a graph of the R squared > value: > > x<-rnorm(10) > y<-rnorm(10) > plot(x,y, main=paste(expression(R^2)," = ",round(summary(lm(y~ > x))$r.squared, digits=3), sep="")) > > I've read various other posts that say expression needs to be taken outside > the paste, but I can't seem to get it work as the following fails > > plot(x,y, main=expression(paste("R^2"," = ",round(summary(lm(y~ > x))$r.squared, digits=3), sep=""))) > > I tried it with title() and didn't get much further either. > > Hmmm, any ideas what am I missing? > > Thanks > > Paul > -- > View this message in context: > http://n4.nabble.com/Paste-expression-in-graph-title-tp1289272p1289272.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] > <http://n4.nabble.com/user/SendEmail.jtp?type=node&node=1289286&i=1> 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O ______________________________________________ [hidden email] <http://n4.nabble.com/user/SendEmail.jtp?type=node&node=1289286&i=2> 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. ________________________________ View message @ http://n4.nabble.com/Paste-expression-in-graph-title-tp1289272p1289286.html To unsubscribe from Paste expression in graph title, click here < (link removed) => . -- View this message in context: http://n4.nabble.com/Paste-expression-in-graph-title-tp1289272p1289291.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org 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.