If x <- round(...whatever...) try: title(capture.output(print(x)))
On Dec 9, 2007 2:15 PM, Ted Harding <[EMAIL PROTECTED]> wrote: > Hi Folks, > > Say I have 2 continuous variables X,Y. > > I can of course plot (X,Y) with > > plot(X,Y,pch="+",col="blue") > > say, and add the regression line from lm(Y~X) > by extracting the coefficients 'a' of Intercept > and 'b' of X from Y.lm <- lm(Y~X). > > Now, however, I want to have not only a general > explanatory title such as > > main="Plot of Y against X" > > but also (and ideally just under the main title > and above the figure region of the plot) the > result of > > round(summary(Y.lm)[[4]],digits=3) > > exactly as shown below: > > Estimate Std. Error t value Pr(>|t|) > (Intercept) 78.636 0.273 287.902 0.000 > X -0.074 0.029 -2.527 0.012 > > It would also be OK to have it as a "subtitle" > below the xlabel (which by default is X" in this case). > > I've been trying to work out how to so this simply, > but without much success. I can see a complicated > way, which involves binding the row and column names, > and the values, of the above output, using paste() > along with "\n" at suitable places, but I'd like to > have something much less intricate than that! > > I'd also like to be able to integrate the solution > nicely with the main title (or the X label) so that > there's no overlap. > > Any suggestions? > > with thanks, > Ted. > > -------------------------------------------------------------------- > E-Mail: (Ted Harding) <[EMAIL PROTECTED]> > Fax-to-email: +44 (0)870 094 0861 > Date: 09-Dec-07 Time: 19:15:08 > ------------------------------ XFMail ------------------------------ > > ______________________________________________ > 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. > ______________________________________________ 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.