Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using inst/extdata with vignette during package checking R 2.14.0

I have a package which contains a csv file which I put in inst/extdata per R-exts. This file is needed for the vignette. If I Sweave the vignette directly, all works well. When I run R --vanilla CMD check however, the check process can't find the file. I know it has been moved into an .Rcheck directory during checking and this is probably part of the problem. But I don't know how to set it up so both direct Sweave and vignette building/checking works.

The vignette contains a line like this:

EC1 <- dot2HPD(file = "../inst/extdata/E_coli/ecoli.dot",
node.inst = "../inst/extdata/E_coli/NodeInst.csv",

and the function dot2HPD accesses the file via:

    ni <- read.csv(node.inst)

Here's the error message:

    > tab <- read.csv("../inst/extdata/E_coli/NodeInst.csv")
Warning in file(file, "rt") :
  cannot open file '../inst/extdata/E_coli/NodeInst.csv': No such file or directory

  When sourcing ‘HiveR.R’:
Error: cannot open the connection
Execution halted

By the way, this is related to this question but that info seems outdated and doesn't quite cover this territory.

I'm on a Mac.

like image 233
Bryan Hanson Avatar asked Nov 14 '11 23:11

Bryan Hanson


1 Answers

Have you tried using system.file instead of hardcoded relative paths?

EC1 <- dot2HPD(file = system.file("inst", "extdata", "E_coli", "ecoli.dot", package = "your_package+name"))
node.inst <- system.file("inst", "extdata", "E_coli", "NodeInst.csv", package = "your_package_name")
like image 77
Max Gasner Avatar answered Sep 29 '22 04:09

Max Gasner