简体   繁体   English

在包检查R 2.14.0期间使用inst / extdata和vignette

[英]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. 我有一个包含一个csv文件的包,我把它放在每个R-exts的inst / extdata中。 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. 但是,当我运行R --vanilla CMD检查时,检查过程找不到该文件。 I know it has been moved into an .Rcheck directory during checking and this is probably part of the problem. 我知道在检查期间它已被移动到.Rcheck目录中,这可能是问题的一部分。 But I don't know how to set it up so both direct Sweave and vignette building/checking works. 但我不知道如何设置它所以直接Sweave和vignette建立/检查工作。

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: 并且函数dot2HPD通过以下方式访问文件:

    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. 我在Mac上。

Have you tried using system.file instead of hardcoded relative paths? 您是否尝试过使用system.file而不是硬编码的相对路径?

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")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM