Hi mate. Great that you figure it out.
However, if you are doing a lot of simulations, there is a short and easier way to do the proportion (and to me, more easier to re-read and elegant):
This chunk of code:
result =ifelse(C >6, 1,0)
count1 = sum(result==1)
length(result)
proportion6 = round(sum(result==1)/length(result),3)
proportion6
is equivalent to:
mean(C > 6)
function mean also estimates probabilities, not just calculates mean. If you want to know other probabilities, just use Boolean style, like if you want to know the % of values equal to 4.37, it should be mean(C == 4.37)
Cheers
Fer