Re: [R] R programming question

2015-09-03 Thread Thierry Onkelinx
Have a look at ?outer outer(1:10, 10:1) Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician

[R] R programming question

2015-09-03 Thread Oleg Portnoy
I have two vectors of probability distribution of the same length n for random variable X and Y. I want to built matrix of two-dimension distribution for X and Y with assumption of independence. P(X=i,Y=j)=P(X=i)*P(Y=j) I want to do this very fast for n=120 and big amount of different distribution

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,

[R] programming question

2007-10-18 Thread raymond chiruka
hie i'm tryimg to generate two survival data using the following code (I know its ugly ) but it seems to repeat two of the variables can any one tell me whats the porblem. n=20 n1=n/2 n2=n/4 a11=1 ;a12=1.4 ;a21=16 ;a22=a12 * a21 t1-array(1,c(n1))

Re: [R] programming question

2007-09-17 Thread Adrian Dusa
On Monday 17 September 2007, you wrote: R 2.6.0 has Reduce; myvec - c(2, 8, 24, 26, 51, 57, 58, 78, 219) Reduce(function(myvec, p) setdiff(myvec, findSubsets2(p)), myvec, myvec) Thanks Gabor, at first I jumped off my chair but... for many input variables it takes ages to reduce the vector.