在软件包检查R 2.14.0中将inst/extdata与小插图一起使用 [英] Using inst/extdata with vignette during package checking R 2.14.0

查看:99
本文介绍了在软件包检查R 2.14.0中将inst/extdata与小插图一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含csv文件的软件包,每个R-exts都将它们放入inst/extdata中.小插图需要此文件.如果我直接编织小插图,则一切正常.但是,当我运行R --vanilla CMD检查时,检查过程找不到文件.我知道它在检查过程中已移入.Rcheck目录,这可能是问题的一部分.但是我不知道如何设置它,所以直接Sweave和小插图构建/检查都可以.

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

,函数dot2HPD通过以下方式访问文件:

and the function dot2HPD accesses the file via:

    ni <- read.csv(node.inst)

这是错误消息:

    > 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.

我在Mac上.

推荐答案

您是否尝试过使用system.file代替硬编码的相对路径?

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

这篇关于在软件包检查R 2.14.0中将inst/extdata与小插图一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆