Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-23 Thread Dan Bolser
On Fri, 22 Jul 2005, Marc Schwartz (via MN) wrote: Ok guys, So I played around with this a bit, going back to Dan's original requirements and using Thomas' do.call() approach with legend(). Gabor's approach using sapply() will also work here. I have the following: # Note the leading spaces here

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-23 Thread Dan Bolser
On Sat, 23 Jul 2005, Dan Bolser wrote: On Fri, 22 Jul 2005, Marc Schwartz (via MN) wrote: Ok guys, So I played around with this a bit, going back to Dan's original requirements and using Thomas' do.call() approach with legend(). Gabor's approach using sapply() will also work here. I have the

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-23 Thread Gabor Grothendieck
Here are a few tweaks. We form a matrix and use round and format to automatically get the right number of decimals and widths right. We have added extra digits to show that they do not affect the result. Also the paste in the R^2 line was eliminated. nn - matrix(c(-10.661, 1.961,

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Dan Bolser
On Thu, 21 Jul 2005, Marc Schwartz (via MN) wrote: [Note: the initial posts have been re-arranged to attempt to maintain the flow from top to bottom] Dan Bolser writes: I would like to annotate my plot with a little box containing the slope, intercept and R^2 of a lm on the data.

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Gabor Grothendieck
Try as.expression(bquote(...whatever...)) On 7/22/05, Dan Bolser [EMAIL PROTECTED] wrote: On Thu, 21 Jul 2005, Marc Schwartz (via MN) wrote: [Note: the initial posts have been re-arranged to attempt to maintain the flow from top to bottom] Dan Bolser writes: I would like to

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Dan Bolser
On Fri, 22 Jul 2005, Gabor Grothendieck wrote: Try as.expression(bquote(...whatever...)) Sob, wimper, etc. my.slope.1 - 3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua.1 - 0.97 text(2,5, paste(Slope: ,

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Thomas Lumley
On Fri, 22 Jul 2005, Dan Bolser wrote: On Fri, 22 Jul 2005, Gabor Grothendieck wrote: Try as.expression(bquote(...whatever...)) Sob, wimper, etc. a-7 plot(1) legend(topleft,legend=do.call(expression, list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1)

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Gabor Grothendieck
On 7/22/05, Dan Bolser [EMAIL PROTECTED] wrote: On Fri, 22 Jul 2005, Gabor Grothendieck wrote: Try as.expression(bquote(...whatever...)) Sob, wimper, etc. my.slope.1 - 3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua.1 - 0.97 text(2,5,

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Gabor Grothendieck
On 7/22/05, Thomas Lumley [EMAIL PROTECTED] wrote: On Fri, 22 Jul 2005, Dan Bolser wrote: On Fri, 22 Jul 2005, Gabor Grothendieck wrote: Try as.expression(bquote(...whatever...)) Sob, wimper, etc. a-7 plot(1) legend(topleft,legend=do.call(expression,

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Gabor Grothendieck
There was an error in the second example. It seems one can use list in the way wanted in legend but not in text so for text one would have to use the do.call approach of Thomas or sapply as shown here: my.slope.1 - 3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 plot(1:5) L -

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Thomas Lumley
On Fri, 22 Jul 2005, Gabor Grothendieck wrote: I think legend accepts a list argument directly so that could be simplified to just: a-7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=L) Except that it wouldn't then work: the mathematical stuff

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Gabor Grothendieck
You are right. One would have to use do.call as you did or the sapply method of one of my previous posts: a - 7 plot(1) L - list(bquote(alpha==.(a)),bquote(alpha^2+1==.(a^2+1))) legend(topleft,legend=sapply(L, as.expression)) On 7/22/05, Thomas Lumley [EMAIL PROTECTED] wrote: On Fri, 22 Jul

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Marc Schwartz (via MN)
Ok guys, So I played around with this a bit, going back to Dan's original requirements and using Thomas' do.call() approach with legend(). Gabor's approach using sapply() will also work here. I have the following: # Note the leading spaces here for alignment in the table # This could be

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-22 Thread Gabor Grothendieck
If one modifies legend by adding a vfont=c(serif, plain) argument to the call to text (which is within the function text2 that is defined within legend) then one can do this: my.slope.1 -3.22 my.slope.2 - 0.13 my.inter.1 - -10.66 my.inter.2 - 1.96 my.Rsqua -0.97 plot(1:5) tt -

[R] Question about 'text' (add lm summary to a plot)

2005-07-21 Thread Dan Bolser
I would like to annotate my plot with a little box containing the slope, intercept and R^2 of a lm on the data. I would like it to look like... ++ | Slope : 3.45 +- 0.34 | | Intercept : -10.43 +- 1.42 | | R^2 : 0.78 |

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-21 Thread Christoph Buser
Dear Dan I can only help you with your third problem, expression and paste. You can use: plot(1:5,1:5, type = n) text(2,4,expression(paste(Slope : , 3.45%+-%0.34, sep = )), pos = 4) text(2,3.8,expression(paste(Intercept : , -10.43%+-%1.42)), pos = 4) text(2,3.6,expression(paste(R^2,: , 0.78, sep

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-21 Thread Dan Bolser
On Thu, 21 Jul 2005, Christoph Buser wrote: Dear Dan I can only help you with your third problem, expression and paste. You can use: plot(1:5,1:5, type = n) text(2,4,expression(paste(Slope : , 3.45%+-%0.34, sep = )), pos = 4) text(2,3.8,expression(paste(Intercept : , -10.43%+-%1.42)), pos = 4)

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-21 Thread Gabor Grothendieck
Use bquote instead of expression, e.g. trees.lm - lm(Volume ~ Girth, trees) trees.sm - summary(trees.lm) trees.co - round(trees.sm$coefficients,2) trees.rsq - round(trees.sm$r.squared,2) plot(Volume ~ Girth, trees) text(10,60, bquote(Intercept : .(trees.co[1,1])%+-%.(trees.co[1,2])), pos = 4)

Re: [R] Question about 'text' (add lm summary to a plot)

2005-07-21 Thread Marc Schwartz (via MN)
[Note: the initial posts have been re-arranged to attempt to maintain the flow from top to bottom] Dan Bolser writes: I would like to annotate my plot with a little box containing the slope, intercept and R^2 of a lm on the data. I would like it to look like...