title: Automatically install dependent libraries for a self-made package
body: <p>I have a question regarding on how to automatically install dependent libraries while installing a self-made package from source.</p>
  
  <p>Basically, the <code>DESCRIPTION</code> file looks like:</p>
  
  <pre><code>Package: mypackage
  Type: Package
  Title: mypackage_title
  Version: 0.1.0
  Author: test 
  Maintainer: test &lt;test @example.com&gt;
  Description: More about what it does (maybe more than one line)
  Depends:
      dplyr, 
      stringr
  License: MIT
  LazyData: TRUE
  RoxygenNote: 5.0.1
  </code></pre>
  
  <p>I followed the <a href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-Dependencies" rel="nofollow">guide</a> and created a <code>.tar.gz</code> file. When I distribute this package, a user will install from the source. In addition, what I expect is that from this source installation, dependent libraries such as <code>dplyr</code> and <code>stringr</code> will be installed automatically if those two are not available. </p>
  
  <p>I tested in a virtual machine but ran into the following errors. So any suggestions on this issue? Thanks in advance!</p>
  
  <pre><code>install.packages("path_to_my_tar.gz", repos=NULL, type="source")
  Error: dependencies 'dplyr', 'stringr' are not available for package
  </code></pre>
  
  <h2>Update: I tried a couple of other approaches but still failed...</h2>
  
  <h3>Approach 1</h3>
  
  <pre><code>install.packages("path/to/my/package", repos = NULL, type = "source")
  ERROR: dependencies 'dplyr', 'stringr' are not available for package 
  </code></pre>
  
  <h3>Approach 2: putting <code>my package</code>, <code>dplyr</code>, and <code>stringr</code> into <code>path/to/my/package/folder</code></h3>
  
  <pre><code>install.packages("path/to/my/package", repos =  "path/to/my/package/folder/", type = "source")
  Warning in install.packages :
    unable to access index for repository path/to/my/package/folder/src/contrib:
    scheme not supported in URL 'path/to/my/package/folder/src/contrib/PACKAGES'
  Warning in install.packages :
    my packageis not available (for R version 3.3.1)
  </code></pre>
  
  <h3>Approach 3: putting <code>my package</code>, <code>dplyr</code>, and <code>stringr</code> into <code>path/to/my/package/folder</code> using <code>contriburl</code></h3>
  
  <pre><code>install.packages("path/to/my/package", contriburl = "path/to/my/package/folder/", type = "source")
  Installing package into my package (as lib?is unspecified)
  Warning in install.packages :
    unable to access index for repository path/to/my/package/folder/:
    scheme not supported in URL 'path/to/my/package/folder/PACKAGES'
  Warning in install.packages :
    my package is not available (for R version 3.3.1)
  </code></pre>
  
  <h3>Approach 4:</h3>
  
  <blockquote>
    <p>install.packages("ProdComp08032016_0.1.2.tar.gz", repos = c("file://C:/Users/TH2/Downloads/", "<a href="http://cran.us.r-project.org" rel="nofollow">http://cran.us.r-project.org</a>"), type = "source")
    Installing package into :/Users/TH2/Documents/R/win-library/3.3?(as ib?is unspecified)
    Warning in install.packages :
      cannot open compressed file '//C:/Users/TH2/Downloads/src/contrib/PACKAGES', probable reason 'No such file or directory'
    Error in install.packages : cannot open the connection</p>
  </blockquote>
  
  <h3>Approach 5:</h3>
  
  <blockquote>
    <p>install.packages("ProdComp08032016_0.1.2.tar.gz", repos = c("C:/Users/TH2/Downloads/", "<a href="http://cran.us.r-project.org" rel="nofollow">http://cran.us.r-project.org</a>"), type = "source")
    Installing package into :/Users/TH2/Documents/R/win-library/3.3?(as ib?is unspecified)
    Warning in install.packages :
      unable to access index for repository C:/Users/TH2/Downloads/src/contrib:
      scheme not supported in URL 'C:/Users/TH2/Downloads/src/contrib/PACKAGES'
    Warning in install.packages :
      package rodComp08032016_0.1.2.tar.gz?is not available (for R version 3.3.1)</p>
  </blockquote>