title: R Error: anyNA() applied to non-(list or vector) of type 'closure' Calls
body: <p>getting this error only when compiling Rmarkdown to a .pdf.  When I run my actual R code, I get no errors. Reproducible error:</p>
  
  <pre><code>library(dplyr)
  
  data &lt;- read.table('http://data.princeton.edu/eco572/datasets/brazilDeathRates1999.dat', header = TRUE)
  data &lt;- mutate(data, n = c(diff(age), 0))
  kfnax &lt;- read.dta("http://data.princeton.edu/eco572/datasets/kfnax.dta")
  data&lt;- inner_join(data, kfnax, by="age")
  data &lt;- rename(data, a = nax)  # for simplicity
  data &lt;- mutate(data, q_males = n * males/(1 + (n - a) * males), p_males = 1 - q_males)
  data &lt;- mutate(data, q_females = n * females/(1 + (n - a) * females), p_females = 1 - q_females)
  
  #makes the last values 1 and 0 respectively for death probability
  data[last, c("q_males","p_males")] = c(1, 0)
  data[last, c("q_females","p_females")] = c(1, 0)
  </code></pre>
  
  <p>It appears the error is triggered on this line:
  <code>data &lt;- mutate(data, q_males = n * males/(1 + (n - a) * males), p_males = 1 - q_males)</code></p>