[R] Help on "looping problem" needed!
Ing. Michal Kneifl, Ph.D.
xkneifl at mendelu.cz
Mon Jul 23 16:40:10 CEST 2007
I am wondering if someone could help me out with following problem:
I have written a for loop which generates a random normal distribution
let us say 1000 times.
When the restriction is met (mean<0.000001), the loop stops, prints
the mean value and plots a histogram.
for(i in 1:1000) {
a<-rnorm(1000,0,.2)
b<-abs(mean(a))
if(b>.000001) next else {print(b);hist(a);break}}
How to reshape the loop when I want to find at least 5 distibutions
that meet my restriction and save them (assign) under
names R1....R5.
Could you help me please?
Michael
More information about the R-help
mailing list