Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread Gavin Simpson
On Fri, 2009-01-09 at 00:22 -0500, stephen sefick wrote: library(StreamMetabolism) snip / plot.e - function(b, w, x, y, z){ a - window.chron(b, w, x, y, z) low - min(b*0.98)+5 high - max(b*1.02)+5 plot(a, ylim=c(low, high)) lines(a*0.98, col=blue) lines(a*1.02, col=red) } plot.e(day,

Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread stephen sefick
WOW, I am not going to post after midnight. Thank you for your response, and this is what I settled on. `plot.e` - function(b, w, x, y, z){ a - window.chron(b, w, x, y, z) low - min(a*0.98)-(min(a)*0.04) high - max(a*1.02)+(max(a)*0.04) plot(a, ylim=c(low, high)) lines(a*0.98, col=blue)

Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread Mike Prager
stephen sefick ssef...@gmail.com wrote: low - min(a*0.98)-(min(a)*0.04) high - max(a*1.02)+(max(a)*0.04) plot(a, ylim=c(low, high)) Unless I am misreading your example, this can be done a little more compactly as: plot(a, ylim = range(a * 0.94, a * 1.06)) -- Mike Prager, NOAA, Beaufort, NC

Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread Gabor Grothendieck
Or even: plot(a, ylim = range(a) + 0.06 * c(-1, 1)) On Fri, Jan 9, 2009 at 2:07 PM, Mike Prager mike.pra...@noaa.gov wrote: stephen sefick ssef...@gmail.com wrote: low - min(a*0.98)-(min(a)*0.04) high - max(a*1.02)+(max(a)*0.04) plot(a, ylim=c(low, high)) Unless I am misreading your

Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread stephen sefick
WOW, Gabor, that is fancy. I have gotten better at this R thing, but have far to go. That is a neat solution. thanks Stephen On Fri, Jan 9, 2009 at 2:22 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Or even: plot(a, ylim = range(a) + 0.06 * c(-1, 1)) On Fri, Jan 9, 2009 at 2:07

Re: [R] Programming Question (setting ylim generally)

2009-01-09 Thread Gabor Grothendieck
Berwin Turlach has pointed out that to be equivalent to the original answer the code should be: plot(a, ylim = range(a) * (1 + 0.06 * c(-1,1))) On Fri, Jan 9, 2009 at 2:22 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Or even: plot(a, ylim = range(a) + 0.06 * c(-1, 1)) On Fri, Jan

[R] Programming Question (setting ylim generally)

2009-01-08 Thread stephen sefick
library(StreamMetabolism) day - (structure(c(10.08, 10.08, 10.05, 10.03, 10, 9.98, 9.96, 9.95, 9.95, 9.96, 9.96, 9.98, 10.01, 10.05, 10.06, 10.09, 10.11, 10.11, 10.13, 10.13, 10.15, 10.15, 10.13, 10.14, 10.11, 10.13, 10.14, 10.13, 10.12, 10.13, 10.14, 10.16, 10.18, 10.19, 10.23, 10.27, 10.33,