title: Difference between dot (.) pronoun and .data pronoun
body: <p>While building my first R package I ran <code>devtools::check()</code> which resulted the following note: <code>no visible binding for global variable ‘.’</code></p>
  
  <p>In order to fix that I tried to be more explicit and changed any instance of <code>.</code> to <code>rlang::.data</code>. While it did solved the <code>devtools</code> note, it made the functions using it to provide wrong output. Here's an example:</p>
  
  <pre><code>library(magrittr)
  library(rlang)
  
  # Creating df with missing values
  iris_w_na &lt;- head(iris)
  iris_w_na[iris_w_na == 0.2] &lt;- NA
  
  ### Replace missing values using .
  # This works
  iris_w_na %&gt;% replace(is.na(.), -99)
  
  # This doesn't
  iris_w_na %&gt;% replace(is.na(rlang::.data), -99)
  
  # This won't work either
  na_indexes &lt;- iris_w_na %&gt;% is.na(rlang::.data)
  
  # But this will work
  na_indexes &lt;- iris_w_na %&gt;% is.na(.)
  iris_w_na %&gt;% replace(na_indexes, -99)
  </code></pre>
  
  <p>Ultimately I went back to use <code>.</code> and solved the <code>devtools</code> note by putting <code>utils::globalVariables(".")</code> in the package documentation.</p>
  
  <p>However I'm still interested to know what are the differences between <code>.</code> and <code>.data</code> and why they behave differently in the above-mentioned example.</p>