相关疑难解决方法(0)

R - 测试使用测试目录外的数据文件

testthat用来测试包含类似于以下文件树的包:

   .
    ??? data
    ?   ??? testhaplom.out
    ??? inst
    ?   ??? test
    ?       ??? test1.r
    ?       ??? tmp_S7byVksGRI6Q
    ?       ?   ??? testm.desc
    ?       ??? tmp_vBcIkMN1arbn
    ?           ???testm.bin
    ?           ??? testm.desc
    ??? R
    ?   ??? haplom.r
    ?   ??? winIdx.r
    ??? tmp_eUG3Qb0PKuiN
        ??? testhaplom.hap2.desc
Run Code Online (Sandbox Code Playgroud)

test1.r文件中,我需要使用该data/testhaplom.out文件作为某个函数的输入数据,但如果我这样做test_file(test1.r),它将更改为inst/test目录并且无法查看数据文件,给出以下错误:

...Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'data/testhaplom.out': No such file or directory
Run Code Online (Sandbox Code Playgroud)

testing r testthat

10
推荐指数
1
解决办法
1747
查看次数

标签 统计

r ×1

testing ×1

testthat ×1