I created my first R package and have a question.
The package runs successfully on my computer. However, if my users (who do not have the packages required) run my package, they will get an error saying the required package is not available. When they manually install that package from CRAN, then my package would work.
According to Hadley Wickam's book (http://r-pkgs.had.co.nz/description.html):
Imports: packages listed here must be present for your package to work. In fact, any time your package is installed, those packages will, if not already present, be installed on your computer (devtools::load_all() also checks that the packages are installed).
I put all the required packages in the Imports field in DESCRIPTION. How come that required package is not installed automatically? Do my users need to install all the required packages before using mine?
Additional background:
- I use the convention package_name::function_name in my script.
- I distribute the package as a binary package.
- The users install the package from their local directory so they can't specify DEPENDENCIES=TRUE when calling install.packages.
What I've done:
- Read Hadley Wickham's book R Packages
- Read Imported packages do not auto-install and R package dependencies but didn't find any information for my issue.
Thank you!
install.packages
will look in the specified repository for dependencies to install. If you are just having users install locally, there is no repository and no dependencies are installed. Dirk recommends using his package drat to make your own little repository with all your dependencies if you don't want to deal with CRAN. – Gregor Thomasinstall.packages
but I suspect that Hadley was using some special purpose function whose deployment was upstream of that text excerpt. – IRTFM