在开发R程序包时,每次更改时都必须重新编译程序包吗? [英] When developing an R package, do I have to recompile the package every time I make a change?

查看:291
本文介绍了在开发R程序包时,每次更改时都必须重新编译程序包吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包R



当我调试一个特定函数或一组函数时,测试函数的最佳方法是什么?



每次我想检查我的更改时,是否必须使用source('function.R')或R CMD build?



(关联emacs ess键绑定额外功劳) http://github.com/hadley/devtools/ ,它提供了一些工具来简化这项任务。

$例如,在对源代码进行更改之后,您将使用函数 install()来构建,安装和重新加载包: $ b

  library(devtools)
install(package_name)
pre>

devtools也使得它更容易:


  • 重新加载完成包:

      load_all(pkg)


  • 使用roxygen2创建或更新文档
    $ b

      document(pkg) 


  • 运行 / inst / test /

      test(pkg)
  • 构建和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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆