Re: [R] Replace NAs in a data frame with elements randomly generated from the beta distribution

2013-04-11 Thread Sibusiso Ndzukuma
Thank you so much for your assistance. A.K's suggestion is exactly what I was looking for. Thanks so much... On Wed, 10 Apr 2013 23:12:25 +0200 peter dalgaard pda...@gmail.com wrote On Apr 10, 2013, at 13:09 , Sibusiso Ndzukuma wrote: Hi there! Please help me, I am trying to replace

[R] Replace NAs in a data frame with elements randomly generated from the beta distribution

2013-04-10 Thread Sibusiso Ndzukuma
Hi there! Please help me, I am trying to replace all NAs in a data frame with numbers randomly generated from the beta(0.1,1) distribution. Firstly I tried looping: MAT -

Re: [R] Replace NAs in a data frame with elements randomly generated from the beta distribution

2013-04-10 Thread arun
Hi, Try this: which(MAT==0)  #[1] 10 19 22 27 28 34 40 46 51 52 MAT[MAT==0]-sapply(seq_along(MAT[MAT==0]),function(x)rbeta(1,0.1,1)) MAT #    X1   X2  X3  X4   X5   X6 #1 0.68 9.731207e-14  0.03005021 0.003249449 1.36e+00 1.180602e-03 #2 9.86

Re: [R] Replace NAs in a data frame with elements randomly generated from the beta distribution

2013-04-10 Thread peter dalgaard
On Apr 10, 2013, at 13:09 , Sibusiso Ndzukuma wrote: Hi there! Please help me, I am trying to replace all NAs in a data frame with numbers randomly generated from the beta(0.1,1) distribution. Firstly I tried looping: MAT -