title: How to easily access hidden environment in package2 from package1?
body: <p>I'm trying to generate latitude and longitude in R using the <code>localgeo</code> package from <code>function1</code> in my own package, however, I can't figure out how to do it without explicitly loading the package.</p>
  <p>How can I enable a function within package1 easy access to package2's hidden environments and their objects?</p>
  <pre><code>### fails
  data &lt;- data.frame(City = c(&quot;New York&quot;, &quot;Miami&quot;, &quot;Los Angeles&quot;), 
  State = c(&quot;NY&quot;, &quot;FL&quot;, &quot;CA&quot;)
  data &lt;- cbind(data, localgeo::geocode(data[[&quot;City&quot;]], data[[&quot;State&quot;]]))
  Error in UseMethod(&quot;tbl_vars&quot;) : 
    no applicable method for 'tbl_vars' applied to an object of class &quot;NULL&quot;
  </code></pre>
  <pre><code>### works
  library(localgeo)
  
  data &lt;- data.frame(City = c(&quot;New York&quot;, &quot;Miami&quot;, &quot;Los Angeles&quot;), 
  State = c(&quot;NY&quot;, &quot;FL&quot;, &quot;CA&quot;)
  data &lt;- cbind(data, geocode(data[[&quot;City&quot;]], data[[&quot;State&quot;]]))
  </code></pre>
  <p>I assume the problem is the function localgeo::geocode() looks like</p>
  <pre><code>function (city, state) 
  {
      data.frame(city = as.character(city), state = as.character(state), 
          stringsAsFactors = FALSE) %&gt;% left_join(.localgeo$geo_db, 
          by = c(&quot;city&quot;, &quot;state&quot;)) %&gt;% select(lon, lat)
  }
  &lt;environment: namespace:localgeo&gt;
  </code></pre>
  <p>and I don't know how to make <code>.localgeo</code> available to my function.</p>
  <hr />
  <p>Updates: It seems that using <code>Depends: localgeo</code> in the <code>DESCRIPTION</code> file of my package not only &quot;loads&quot; but &quot;attaches&quot; <code>localgeo</code> and thus I can run the <code>localgeo::geocode()</code> without a problem. Of course,</p>
  <blockquote>
  <p>Unless there is a good reason otherwise, you should always list packages in Imports not Depends. That’s because a good package is self-contained, and minimises changes to the global environment (including the search path). The only exception is if your package is designed to be used in conjunction with another package. For example, the analogue package builds on top of vegan. It’s not useful without vegan, so it has vegan in Depends instead of Imports. Similarly, ggplot2 should really Depend on scales, rather than Importing it. <a href="http://r-pkgs.had.co.nz/namespace.html" rel="nofollow noreferrer">Namespace</a></p>
  </blockquote>
  <p>Is it possible to access hidden environments in <code>package2</code> in my <code>package1</code> without &quot;attaching&quot; <code>package2</code>?</p>
  <hr />
  <p>To those seeking an MWE, the challenge: <a href="https://gitlab.com/mwes/MWE.HiddenEnvironment.localgeo.Import" rel="nofollow noreferrer">solve this MWE</a></p>