Add Months to Date in R (if Data Exists)
<p>I'm having some issues adding months to a date in R, specifically I have a column "Date" that may or may not have a date and another column "Months" that may or may not have a positive integer. If there is both a date and integer I want to add them, something like this:</p>

<pre><code>library(lubridate)
df$End &lt;- ifelse(is.na(df$Start) | is.na(df$Months),"",df$Start %m+% months(ol$Months))
</code></pre>

<p>The error I keep getting is as follows:</p>

<pre><code>Error in NextMethod(.Generic) : 
  NAs are not allowed in subscripted assignments
</code></pre>

<p>Any ideas? Thanks for your help.</p>