2

I've been struggling to get the example code for a function working using devtools::check(), because the data required for the example is not in .RData format. Unfortunately, the way the function is written, .RData cannot be loaded and work properly. The function takes in a list of filenames and performs an action on them collectively.

Therefore, example code must be written in a way that check() is able to access a folder and list the files therein. Using the function on my own computer, I input

setwd("/Users/mydirectory")
myfilelist <- list.files(pattern = "mypattern")
output <- myfunction(myfilelist, ...)

and everything is groovy. But this doesn't work with devtools because @examples doesn't know how to access subdirectories on my computer. check() pulls the following error:

base::assign(".ptime", proc.time(), pos = "CheckExEnv")

This is almost undoubtedly because check() doesn't know where to look for the data. I'd like it to look toward github to access the online data repository.

I found this brief conversation regarding a similar roxygen-related problem, but overall I haven't seen much advice on how to work through it. I think that perhaps this issue starts to get a little closer to my situation, but here the user failed to export a function, rather than bind data to an example.

I don't think I'm looking for a pull function (though the end goal is to pull data...), does anyone have advice moving forward? I have the data stored in the inst/extdata folder on github, so while I don't really have something reproducible for you all I'm hoping you might have some thoughts.

Edit: I worked around the problem using @alistaire's advice below, and guiding the roxygen to the package directory (updated on github) and also using \dontrun{}. However, I am leaving the question unanswered for now because I think accessing data stored in github should still be somehow possible and we haven't yet addressed that.

JepsonNomad
  • 187
  • 2
  • 15
  • 1
    Totes diggin the use of "jive" in the question title. Somewhat more seriously, is the loading of the data necessary, or could you just put it in `.rbuildignore` or something like that? – RobertMyles Oct 31 '17 at 17:17
  • @RobertMc Does `.rbuildignore` skip processing of the example when using `check()`? If so, will that impact the possibility of submitting to CRAN? As I understand, errors pulled in `check()` pretty much eliminate acceptance by CRAN. – JepsonNomad Oct 31 '17 at 17:20
  • 1
    Sounds like some version of `list.files(system.file('misc', package = 'utils'))`, but more context is necessary. Or just set the example so it doesn't run and ignore the issue. – alistaire Oct 31 '17 at 17:27

0 Answers0