Hmm. I can't attach an .Rmd file- not allowed and it's too long to paste all in a code block. So I'll paste the block containing line 476 (though I can't see an issue in that line of code? 476 begins: plot(density(rnorm(100000)...:
```{R, results='hide', echo = FALSE}
colors <- colorblind_pal()(8)
moment <- c(1,2,3,4,5,10,15,20)
layout(mat = matrix(c(1,1,1,1,2,3,4,5,6,7,8,9,10,10,10,10), nrow = 4, ncol = 4, byrow = TRUE),
heights = c(.75,2.25,2.25,1)
)
par(mar=c(0,0,4,0))
plot.new()
title(main =expression(paste('Probability density function of normal distributions \nMoments: mu (',mu ,"), ", "sigma (",sigma,")",sep = '')), cex = 2)
par(mar=c(4,4,1,1))
lapply(c(1:8), FUN = function(i){
plot(density(rnorm(100000 , mean = 0, sd = moment[i])), col = colors[i], ylim = c(0,.4), xlim = c(-5*moment[i],5*moment[i]), pch=16, ylab = "Density", xlab = "x",
main = "")
})
par(mar=c(1,1,1,1))
plot.new()
legend('bottom', legend = moment, fill= colorblind_pal()(6), title = expression(paste('mu (', mu ,")", sep = "")), cex=1, horiz = TRUE)