I'm trying to visualize the histogram of two distributions and then visualize the distribution in the same pdf graph.
First of I'm trying to simulate 100 to 5000 draws from a normal distribution with µ = 6 och σ = 2.
Attempt:
x <-rnorm(n=100, mean=6, sd=2)
hist(x, probability=TRUE)
y <-rnorm(n=5000, mean=6, sd=2)
hist(x, probability=TRUE)
Which I belive to be correct for visualizing the histograms. However, I don't understand how to display the pdf of both graphs in the same graph. I found a function called pdfPlot() but couldn't make it work.
How do I combine x and y into one graph and show the pdf of them?