Important note - in the coursera p-value plot generation R script, you have an extra "sample(c(2,2,1))" that had no effect, but that was changing the seed sequence. Here you add a FALSE statement to "make sure" it doesn't have any effect, even though there's not way it could have had an effect the previous way it was written because all pbins values are < 5.

If you want to recreate the exact same plots done for the coursera, stuff you could use this script. If you wanted to take it out you would get essentially the same plots, but with a different random seed chain. Note, the first plot would be the same, but afterwards the sample() function would throw off the seed for the remaining e<-rnorm(n) lines.

Effectually it's the same code, and it's still weirdly inefficient, but it's less dangerous looking here.

You made a mistake, and were lucky that there was no effect of it.