title: How to import data from another package
body: <p>I have one package (say <code>testpackage1</code>) which contains a method called <code>readData()</code>.</p>
  
  <p>This method reads a <code>test.data.rda</code> file that is placed in the data folder of <code>testpackage1</code> and after some operations, returns a data frame.</p>
  
  <p>This is the only R file in <code>testpackage1</code>:</p>
  
  <pre><code>#' Reads data and transforms it
  #'
  #' @return a data.frame
  #' @export
  #'
  #' @examples my.df &lt;- readData()
  readData &lt;- function() {
    return(subset(test.data, x &lt; 50))
  }
  
  initPackage &lt;- function() {
    test.data &lt;- data.frame(x = seq(1, 100),
                            y = seq(101, 200))
    devtools::use_data(test.data, overwrite = TRUE)
  }
  </code></pre>
  
  <p>Calling the <code>initPackage</code> method creates the data frame and saves it as a .rda file in the data folder.</p>
  
  <p>Now I have created a second package named <code>testpackage2</code>, that also has only one R file:</p>
  
  <pre><code>#' Gets the data
  #'
  #' @import testpackage1
  #' @export
  #'
  #' @examples hello()
  hello &lt;- function() {
    print(testpackage1::readData())
  }
  </code></pre>
  
  <p>I built both packages, then started a fresh R session and typed:</p>
  
  <pre><code>&gt; library(testpackage2)
  &gt; hello()
  </code></pre>
  
  <p>But I have this error:</p>
  
  <pre><code>Error in subset(test.data, x &lt; 50) : object 'test.data' not found 
  4. subset(test.data, x &lt; 50) at hello.R#8
  3. testpackage1::readData() 
  2. print(testpackage1::readData()) at hello.R#8
  1. hello()
  </code></pre>
  
  <p>If I type <code>require(testpackage1)</code> before calling method <code>hello()</code>, then it works.</p>
  
  <p>But I thought loading <code>testpackage2</code> would have automatically loaded its dependencies. I could add <code>require(testpackage1)</code> in the <code>hello()</code> function, but it seems redundant with the <code>@import</code> statement.</p>
  
  <p>Moreover, the <code>readData()</code> IS correctly imported, why not the data? Should I somehow export the data as well?</p>