title: Why does my lognormal curve not appear? (R)
body: <p>I am attempting to to plot a histogram with a lognormal curve over it. For some reason the curve is not appearing in the plot. My matrix of data has NAs in it so I tried to remove them in the function by omission.
  This is the data I'm using right now.</p>
  <pre><code>c(767.25, 759.5, 770.5, 783.5, 773.25, NA, NA, NA, 793.25, 797.25, 
  803.5, 824.5, NA, NA, 835.25, 838.25, 856.5, 846.25, 825.75, 
  NA, NA, 840.75, 835.75, 863, 859, 853.75, NA, NA, 858.75, 874.25, 
  886, 862.75, 867, NA, NA, 872, 840.25, 837, 850.75, 822.25, NA, 
  NA, NA, 762.25, 763, 747.25, 776.5, NA, NA, 782.5)
  </code></pre>
  <pre><code>Lognormal_Conversion &lt;- function(z){
    
    #Colors for graph and line
    #user1 &lt;- tolower(readline(prompt = &quot;Colors for graph and line (a,b): &quot;))
    #ColorListParsed &lt;- unlist(lapply(strsplit(user1, ',')[[1]], as.character))
    #ColorBars &lt;- toString(ColorListParsed[1])
    #ColorLine &lt;- toString(ColorListParsed[2])
    
    #removing the NAs
    z2 &lt;- na.omit(z)
    
    #Moments
    u &lt;- mean(z2)
    std &lt;- sd(z2)
    lu &lt;- exp(u + (std^2)/2)
    lsd &lt;- sqrt( (exp(std^2) - 1) * exp(2*u + std^2) )
    lskew &lt;- (exp(std^2) +2) * sqrt( (exp(std^2) - 1) )
    lkurt &lt;-  exp(4*std^2) + 2 * exp(3 * std^2) + 3 * exp(2 * std^2) - 6
    
    #Making lognormal line
    Logline &lt;- dlnorm(x = z2, meanlog = lu, sdlog = lsd)
    
    #Getting variable name for plot title
    VarName &lt;- deparse(substitute(z))
    
    #Making the graph
    zseq &lt;- seq(min(z2), max(z2))
    hist(z2, main = paste(&quot;Histogram of &quot;, VarName))
    lines(z2, Logline, lty = 1, col = &quot;pink&quot;, lwd = 2) #Adding lognormal line
    
    
  }
  
  </code></pre>
  <p>I then get the following message:</p>
  <pre><code>Warning message:
  In dlnorm(z2, meanlog = lu, sdlog = lsd) : NaNs produced
  </code></pre>