在开发R程序包时,每次更改时都必须重新编译程序包吗? [英] When developing an R package, do I have to recompile the package every time I make a change?
问题描述
我正在开发一个包R
当我调试一个特定函数或一组函数时,测试函数的最佳方法是什么?
每次我想检查我的更改时,是否必须使用source('function.R')或R CMD build?
(关联emacs ess键绑定额外功劳) http://github.com/hadley/devtools/ ,它提供了一些工具来简化这项任务。
$例如,在对源代码进行更改之后,您将使用函数 install()
来构建,安装和重新加载包: $ b library(devtools)
pre>
install(package_name)
devtools也使得它更容易:
重新加载完成包:
load_all(pkg)
使用roxygen2创建或更新文档
$ bdocument(pkg)
运行
/ inst / test /
:test(pkg)
$ p
构建和R CMD检查:
check( pkg)
I am developing a package in R
When I am debugging a particular function or set of functions, what is the best way to test the function?
Do I have to either use source('function.R') or R CMD build each time I want to check my changes?
(extra credit for associated emacs ess key-bindings)
解决方案See also http://github.com/hadley/devtools/ which provides some tools to make this task easier.
for example, after making changes to source code, you build, install, and reload a package with the function
install()
:library(devtools) install("package_name")
devtools also makes it easier to:
Reload complete package:
load_all("pkg")
Create or update documentation using roxygen2
document("pkg")
run all scripts in
/inst/test/
:test("pkg")
build and R CMD check:
check("pkg")
这篇关于在开发R程序包时,每次更改时都必须重新编译程序包吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!