I don't know why geom_freqpoly is not graphing. When I run the chunk I only see the histogram but not the line graph.
library(ggplot2)
lambda1 = 1/2
sequence = seq(1, 10000, by=1)
df1 = tibble(x=seq(1, 10000, by=1), expo1 = lambda1*exp(-(lambda1)*x))
lambda2 = 1/5
df2 = tibble(x=seq(1, 10000, by=1), expo2 = lambda2*exp(-(lambda2)*x))
ggplot() +
geom_histogram(aes(x=expo2, y=..density..), binwidth=.5, colour="blue", fill="white") +
geom_histogram(aes(x=expo1, y=..density..), binwidth=.5, colour="red", fill="white") +
geom_freqpoly(data=df2, aes(x=expo2, y=..density..), binwidth=.5, colour="blue") +
geom_vline(aes(xintercept=mean(expo2)), color="blue", linetype="dashed", size=1) +
geom_density(alpha=.2, fill="#FF6666") +
geom_freqpoly(data=df1, aes(x=expo1, y=..density..), binwidth=.5, colour="red") +
geom_vline(aes(xintercept=mean(expo1)), color="red", linetype="dashed", size=1) +
geom_density(alpha=.2, fill="#FF6666") +
xlim(0,10) +
ylim(0,0.5)+
ggtitle("Distribution of averages of random exponential distribution with their means", "theta = 2 in red and theta = 5 in ")+
xlab("Averages of the distribution")+
ylab("Density")
