I have a question regarding on how to automatically install dependent libraries while installing a self-made package from source.
Basically, the DESCRIPTION
file looks like:
Package: mypackage
Type: Package
Title: mypackage_title
Version: 0.1.0
Author: test
Maintainer: test <test @example.com>
Description: More about what it does (maybe more than one line)
Depends:
dplyr,
stringr
License: MIT
LazyData: TRUE
RoxygenNote: 5.0.1
I followed the guide and created a .tar.gz
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 dplyr
and stringr
will be installed automatically if those two are not available.
I tested in a virtual machine but ran into the following errors. So any suggestions on this issue? Thanks in advance!
install.packages("path_to_my_tar.gz", repos=NULL, type="source")
Error: dependencies 'dplyr', 'stringr' are not available for package
Update: I tried a couple of other approaches but still failed...
Approach 1
install.packages("path/to/my/package", repos = NULL, type = "source")
ERROR: dependencies 'dplyr', 'stringr' are not available for package
Approach 2: putting my package
, dplyr
, and stringr
into path/to/my/package/folder
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)
Approach 3: putting my package
, dplyr
, and stringr
into path/to/my/package/folder
using contriburl
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)
Approach 4:
install.packages("ProdComp08032016_0.1.2.tar.gz", repos = c("file://C:/Users/TH2/Downloads/", "http://cran.us.r-project.org"), 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
Approach 5:
install.packages("ProdComp08032016_0.1.2.tar.gz", repos = c("C:/Users/TH2/Downloads/", "http://cran.us.r-project.org"), 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)