title: How to properly include dependencies in R-package?
body: <p>I was trying now for several hours to build a package in R and getting a bit desperate about how slowly I progress. I managed quite fast to build a package with no dependencies, everything works fine. Due to recommendations in several posts, I'm using R Studio, devtools and Roxygen2 (being on Windows). With dependencies, I get problems when I CHECK (e.g. with devtools::check() ):</p>
  
  <blockquote>
    <p>checking dependencies in R code ... NOTE Namespace in Imports field
    not imported from: 'ggplot2'   All declared Imports should be used.
    See the information on DESCRIPTION files in the chapter 'Creating R
    packages' of the 'Writing R Extensions' manual.</p>
  </blockquote>
  
  <p>Furthermore, check() deletes the <code>import(ggplot2)</code> line in the NAMESPACE. If I do check(document=F), it gives an cryptic error about a <code>digest</code> package which is not loaded. I read 'Writing R Extensions' - 1.1.3 Package Dependencies and Hadley's Wiki concerning how to write packages, but couldn't solve my problem. DESCRIPTION and NAMESPACE files of other R packages from CRAN don't look different to mine (for my eyes)?</p>
  
  <p><strong>Question:</strong> What am I doing wrong? Sorry for such a basic question, but I am at a loss and most step-by-step tutorials I've seen so far stop before explaining dependencies.</p>
  
  <p>So far, I have 3 files: <br>
  A DESCRIPTION:</p>
  
  <pre><code>Package: test
  Type: Package
  Title: Foo
  Version: 1.0
  Date: 2014-03-21
  Author: Bar
  Maintainer: Foo &lt;bar@mail.com&gt;
  Description: Blubb
  Imports:
      ggplot2
  License: GPL-3
  </code></pre>
  
  <p>A NAMESPACE:</p>
  
  <pre><code>export(is.equal.null)
  import(ggplot2)
  </code></pre>
  
  <p>A R-File:</p>
  
  <pre><code>#' Extension of compare to include NULLs
  #'
  #' Works as an extension to usual compare
  #' Compares two basic objects which in addition to usual compare can be NULL
  #' Intuitive output: TRUE if both are equal or NULL resp., FALSE if both are unequal or only one is NULL
  #'
  #' @param obj1 Basic object like \code{numeric, char, boolean, NULL}
  #' @param obj2 Basic object like \code{numeric, char, boolean, NULL}
  #' @keywords compare
  #' @export
  #' @examples
  #' is.equal.null(5,5)  # TRUE
  #' is.equal.null(5,NULL)  # FALSE
  #' is.equal.null(NULL,NULL)  # TRUE
  is.equal.null &lt;- function(obj1, obj2) {
    # Small helper function to generalize comparison to comparison of NULL
    # returns TRUE if both are NULL, and FALSE if only one of the objects is NULL
    bool &lt;- obj1==obj2 
    #qplot(obj1)
    if (length(bool)) return(bool)
    if (is.null(obj1) &amp; is.null(obj2)) return(TRUE)
    return(FALSE)
  }
  </code></pre>