title: How to I draw a line plot and ignore missing values in R
body: <p>I have two variables that I want to plot in R, one of them (B) is missing some data points. I want to draw a line between the existing points in B</p>
  <p>This the image I get from R
  <a href="https://i.stack.imgur.com/27SrO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/27SrO.png" alt="R output" /></a></p>
  <p>I want to connect the blue points at 1, 5, and 10. If I replace NA with zeros, I get the same image since my Y range starts from 1. And I do not want to have the line going down to zero and making a point there.</p>
  <p>This is the code I have so far:</p>
  <pre><code>A&lt;-c(187.674646,101.734756,85.674646,57.327278,51.207435,49.438306,47.939082,44.17294,42.613277,39.916711)
  B&lt;-c(27.13350001,     NA   ,     NA   ,   NA   ,41.5181   ,     NA  ,     NA  ,   NA    ,  NA     ,79.18489934)
  
  plot(A, type=&quot;o&quot;, pch=16, cex=1.5, lty=1, lwd=0.25,  col=&quot;red&quot;, ylim=graph_range, log=&quot;y&quot;, axes=FALSE, ann=FALSE)
  axis(1, at=1:10, lab=c(&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;,&quot;9&quot;,&quot;10&quot;),cex.axis=0.95, las=1)
  yticks &lt;-c(10,100,1000,10000)
  axis(2, at=yticks, lab=c(&quot;10&quot;,&quot;100&quot;,&quot;1000&quot;,&quot;10000&quot;),cex.axis=0.95)
  box()
  lines(B, type=&quot;o&quot;, pch=16, cex=1.5, lty=1, lwd =0.25, col=&quot;blue&quot;)
  </code></pre>