7

Hi I am following the tutorial here from Hilary and here from Hadley Wickham trying to create a dummy package.

However, my package need some external dependencies XML and RCurl in this case, when I run the command document, it will complain that:

> setwd('/home/datafireball/projects/Rprojects/rgetout/rgetout')
> document()
Error: could not find function "document"
> library(devtools)
> document()
Updating rgetout documentation
Loading rgetout
Loading required namespace: XML
Error in (function (dep_name, dep_ver = NA, dep_compare = NA)  : 
  Dependency package XML not available.
> 

Here is my DESCRIPTION file.

Package: rgetout
Title: A R package to get all the outlinks for a given URL
Version: 0.1
Authors@R: "Eric Cartman <Eric.Cartman@gmail.com> [aut, cre]"
Description: This package is intended to include as much web extraction functionality as much as     possible. It starts with one function. getout will extract
all the outlinks for a given URL with a user-agent that you can customize.
Depends: R (>= 3.0.2)
Imports:
    XML,
    RCurl
License: MIT
LazyData: true

Here is the source code github repo if you want to get more info.

4
  • 2
    I presume that you have installed 'XML' and 'RCurl' on your system....
    – mnel
    Oct 3, 2014 at 3:22
  • @mnel, actually no, I tested the code on my windows box with XML and RCurl installed. Then I copied the code to my ubuntu virtualbox expected it will follow the description and install the packages?
    – B.Mr.W.
    Oct 3, 2014 at 3:47
  • 1
    You need to do a library(devtools) or require(devtools) before you can call the document() function.
    – hrbrmstr
    Oct 3, 2014 at 3:49
  • You need to put packages you want "auto-installed" under Depends: in the DESCRIPTION file, not Imports:
    – hrbrmstr
    Oct 3, 2014 at 3:51

2 Answers 2

6

If you are having problems with this, even when you have the packages installed and loaded, I suggest you to do the following.

  • Delete the Imports: and Suggests: entries of your DESCRIPTION file.
  • Make sure you have usethis working by doing library(usethis)
  • Now start adding the libraries to your DESCRIPTION file, by running the following command on your console: usethis::use_package("dplyr") for any Imports: you need. Repeat this step for every library that is required.

In my case, dplyr was the one refusing to load. You can decide where the package will be located by doing: usethis::use_package("dplyr", "Suggests").

2

It is assumed that you will have the required tools / dependencies for developing a package when you are doing so.

utils::install.packages has a dependencies argument that will attempt to install uninstalled packages on which a package depends / (in whichever way they are dependent (suggests/ depends/linkingTo).

devtools::install_github will perform similarly.

Installing a package and documenting it as a component of development are quiet different activities .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.