我正在使用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
在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