I am a beginner in R.
I am working on creating a relative frequency histogram (from random uniform numbers with 1,000 samples of 2) with a normal curve over-layed on top.
So far this is my attempt at the code:
set.seed(32423432)
x1 <-runif(2000,0,1)
m<-matrix(x1,ncol=2)
msum<-apply(m,1,sum)
bins=seq(-4,4,by=.2)
msum2<-msum/2
msum2<-msum2-(1/2)
msum2<-msum2*sqrt(2)
hist(msum2,breaks=bins, freq= FALSE, right=FALSE)
I have a few problems with this:
- the percentage on the y-axis makes no sense to me (I would expect to see something between 0 and .5)
- I should see way more bins
- I have no idea how to change the x-axis labels to every .4
- I cannot seem to get a normal curve on top of this histogram