如何编辑和调试R库源码 [英] How to edit and debug R library sources

查看:104
本文介绍了如何编辑和调试R库源码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的R脚本中添加了一个名为吸墨纸的库,其中有一个bug。有没有一个简单的方法来编辑源码来尝试调试问题?

解决方案

查找 trace 浏览器函数,它们是R中用于调试的基本工具。假设您想编辑函数的来源 foo ,然后说

  trace(foo,edit = TRUE)

将在编辑器中打开foo的源码你要改变但是,这是为了进行交互式调试;软件包中的源文件不会更改。所以一旦你找到了这个bug,你需要把这个更改的包源文件修改为永久的。


I've included a library called blotter in my R script which has a bug in it. Is there an easy way for me to edit the source to try and debug the issue?

解决方案

Look up the trace and browser functions, they are the basic tools in R for debugging. Say you want to edit the source of function foo, then saying

trace("foo",edit=TRUE)

will open up the source of foo in the editor for you to change. However, this is for interactive debugging; the source files in the packages are not changed. So once you have found the bug, you need to change the package source files for the change to be permanent.

这篇关于如何编辑和调试R库源码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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