Re: [R] One pdf file with plots and text output

2007-10-17 Thread Rainer M Krug
Dirk Eddelbuettel wrote: > On 17 October 2007 at 10:44, Rainer M Krug wrote: > | I create one pdf file with plots via pdf() and one text file with text > | via sink() that works very nice. But I would prefer to have one pdf file > | with plots and the text which I store in the te

[R] Sum of binominal distributed random numbers

2007-10-23 Thread Rainer M Krug
Hi I have two vectors, prob and size, and I want to add the random deviates of these two, i.e. sum( sapply( 1:length(prob), function(n){ rbinom(1, size(n), prob(n) } ) ) My problem is that I have to do this for a large number of value combinations. Is there a

[R] "flipping" vector and matrix

2007-10-23 Thread Rainer M Krug
Hi I have a vector x <- c(1, 2, 3, 4, 5) and I want to "flip" it around, i.e. I need 5, 4, 3, 2, 1 Is there a ssolution apart from y <- x[length(x):1] I am also looking for the same for a matrix M, i.e. 1 2 3 4 5 6 7 8 9 should become 7 8 9 4 5 6 1 2 3 again, I am using M[1:dim(M)[1],

Re: [R] "flipping" vector and matrix

2007-10-23 Thread Rainer M Krug
you gave: >> x > [,1] [,2] [,3] > [1,]123 > [2,]456 > [3,]789 >> >> apply(t(x),1,rev) > [,1] [,2] [,3] > [1,]789 > [2,]4 5 6 > [3,]123 > > > On Tue, 23 Oct 2007, Rainer M

Re: [R] "flipping" vector and matrix

2007-10-23 Thread Rainer M Krug
b <- matrix(1:9,3,3) > > b > [,1] [,2] [,3] > [1,]147 > [2,]258 > [3,]369 > > arev(b) > [,1] [,2] [,3] > [1,]963 > [2,]852 > [3,] 741 > > > > > > > >

[R] "adding" matrix of smaller dimensions to matrix of larger dimensions and "apply" question

2007-10-23 Thread Rainer M Krug
Hi I have another question concerning matrices: I have two matrices: > b <- matrix(1:25,5,5,byrow=T) > b [,1] [,2] [,3] [,4] [,5] [1,]12345 [2,]6789 10 [3,] 11 12 13 14 15 [4,] 16 17 18 19 20 [5,] 21 22 23 24 25 and > d

Re: [R] analytical solution to Sum of binominal distributed random numbers?

2007-10-24 Thread Rainer M Krug
element of the vector > 'size', which in R is written 'size[ n ]' . > > In which case > > sum (rbinom( length(prob) , size, prob ) ) > > works. > > Chuck > > On Tue, 23 Oct 2007, Rainer M Krug wrote: > >> Hi >> >> I have

Re: [R] analytical solution to Sum of binominal distributed random numbers?

2007-10-24 Thread Rainer M. Krug
ded recipient, please notify Faculty of Agricultural > Sciences immediately and delete this email. > > > > > >> -Oprindelig meddelelse- >> Fra: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] På vegne af Rainer M Krug >> Sendt: 24. oktober 2007 09:11 >

Re: [R] analytical solution to Sum of binominal distributed random numbers?

2007-10-24 Thread Rainer M. Krug
= 0.5) > Z <- X + Y > > d(Z)( 0:18 ) # the pmf > r(Z)( n = 5 ) # random variates > > Please note, however, that size and prob must be of length 1. > > Best, > Jay > > On 10/24/07, Rainer M. Krug <[EMAIL PROTECTED]> wrote: >> Frede Aakmann Tøge

<    1   2   3   4   5