在包检查 R 2.14.0 期间使用带有小插图的 inst/extdata [英] Using inst/extdata with vignette during package checking R 2.14.0

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

问题描述

我有一个包,其中包含一个 csv 文件,我在每个 R-exts 中放入了 inst/extdata.小插图需要此文件.如果我直接 Sweave 小插图,一切正常.但是,当我运行 R --vanilla CMD check 时,检查过程找不到该文件.我知道在检查过程中它已被移动到 .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天全站免登陆