2

In R, I have developed my own package for work (let's call it 'foo') and I have built the package and produced a binary foo.zip with the dependencies (e.g. ggplot2) listed in the description file.

When I use the R package installer in the packages tab it doesn't automatically download the dependencies from CRAN. Ultimately I don't want the end user to have to do this and I don't intend to load it to CRAN for the time being.

I have a way with: devtools::install_dep but I don't want the user to have to do this!

divibisan
  • 11,659
  • 11
  • 40
  • 58
JamesM95
  • 21
  • 2

2 Answers2

1

Use the remotes package:

remotes::install_deps("~/RStudio/foo/foo.tar.gz")
James Hirschorn
  • 7,032
  • 5
  • 45
  • 53
0

You don't say how you're expecting users to install the package. I believe if you put it on the web on a CRAN-like repository, and tell your users to install from there, R will by default install dependencies. This involves telling them how to add your repository to the repository list, so it might be just as easy to ask them to install devtools and use devtools::install_dep.

Another possibility is to distribute your package in a source version; then this answer: https://stackoverflow.com/a/38902163/2554330 gives ideas how to proceed. One that works for me to install something like "~/RStudio/foo/foo.tar.gz" is

install_url(paste0("file://", normalizePath("~/RStudio/foo/foo.tar.gz")))

If you are on Windows, you'll probably need a slightly different way to construct the URL.

Distributing binary packages is only convenient if all your users use the same version of R as you do; they aren't guaranteed to work if the minor version number changes.

user2554330
  • 37,248
  • 4
  • 43
  • 90
  • I had planned to just send the binary source by email When I try install.packages("~/RStudio/foo/foo.tar.gz", repos = NULL, type = "source", dependencies = TRUE) I get the error: ERROR: dependency 'ggplot2' is not available for package 'foo' * removing 'C:/Users/jmm/Documents/R/R-3.5.1/library/foo' In R CMD INSTALL Warning in install.packages : installation of package ‘C:/Users/jmm/Documents/RStudio/foo/foo.tar.gz’ had non-zero exit status – JamesM95 Sep 25 '18 at 15:17
  • Yes, but that's not what my link suggests you should do. – user2554330 Sep 25 '18 at 15:20