title: Overlay a t-distribution to my histogram using R?
body: <p>How can I overlay a t-density to my histogram using R? Here's my function:</p>
  
  <pre><code>simfun &lt;- function(a=56.25102409,b=1.78977412,c=0.08664925,n=18,x1.sd=18.87671,x2.sd=18.87671,e.sd=18.87671) {
     X1 &lt;- rnorm(n, mean=0, sd=x1.sd)
     X2 &lt;- rnorm(n, mean=0, sd=x2.sd) 
     e &lt;-  rnorm(n, mean=0, sd=e.sd)
     Z &lt;- a+b*X1+c*X2+e 
     data.frame(X1,X2,Z)
  }
  
  statfun &lt;- function(samples) {
      coef(lm(Z~X1+X2,data=samples))
  }
  
  library(plyr)
  B=raply(1000,statfun(simfun()))
  
  (hist(B[,2]))
  </code></pre>