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.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With