In my code, I would like to replace entries in t with entries from a random normal distribution.
n<-10 > nl<-round(1.5+rexp(1,rate=2) rate=2)) > nl [1] 2 > r<-1:n > s<-sort(sample(r,nl)) > t<-match(r,s) > r [1] 1 2 3 4 5 6 7 8 9 10 > s [1] 3 8 >t [1] NA NA 1 NA NA NA NA 2 NA NA t.random<-function(x) {for(i in 1:n) ifelse(x[i]!=NA, x[i]<-rnorm(1), x[i]<-NA} t.random(t) t [1] NA NA 1 NA NA NA NA 2 NA NA Thank you for your time, Diana Verzi Associate Professor of Mathematics ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.