R包开发的时候怎么测试?

w
wdong
楼主 (未名空间)

请教一个R开发流程的问题。

比如我有一个R包的源代码,正常使用流程是:

1. 在源代码内用install.packages(pkgs='.', repo=NULL)安装包
2. 在测试程序里用library(...)导入包,或者用::加qualification用包里的内容。

好了,现在假设我要不断修改测试这个包,我不希望我改一行就需要走第1步重新安装
才能测试。有没有什么办法能够直接加载源程序目录中的包,而不需要先安装?

h
huangrh

可以试一下 source('C:/path/to/file.R')。
另外推荐用Rstudio来写,and if you check the box then
RStudio do source for you when you save a R file.
m
magliner

我老都是把重要的东西放进函数里,然后‘编译’/run这个函数,修改一行,编译一下,测试一下;不需要和‘包’/package打交道。等把函数写好了,再生成一个包。
不太科学,我是不想和各种包打交道。
c
cb2

不知道这是不是你要的.
例如
trace(limma:::barcodeplot,edit=TRUE) ## this will open an editor to allow
modifying the function

untrace(limma:::barcodeplot) # stop tracing
g
guanshui

R package 完整的testing tutorial:https://r-pkgs.org/tests.html
不谢
g
guanshui

R package 完整的testing tutorial:
https://r-pkgs.org/tests.html

不谢