A For loop to replace vector value
问题 I couldn't figure out what's the problem on my code. Basically i'm trying to do a small version of Monte Carlo simulation. This is my input mydata=[1,4,20,23,37] prediction=c(0,0,0,0,0,0,0,0,0,0,0,0) randomvar=runif(12,0,1) and then i have this condition: if i-th value of randomvar is > 0.97, replace i-th value of prediction with 5th data from mydata else if i-th value of randomvar is > 0.93, replace i-th value of prediction with 4th data from mydata else if i-th value of randomvar is > 0.89,