如何在Rstudio中调试单独的代码块?

发布于 2025-01-31 04:26:34 字数 172 浏览 3 评论 0原文

R内核要求在激活任何断点之前“来源”文件 - 这意味着您必须先在控制台中有效地执行整个脚本。只有在您的脚本短而分开的块和独立功能(例如一袋工具)中,这是可以接受的。但是,如果您的脚本由原始的代码线组成,这些代码线无法很好地工作,有些甚至不工作或错误?
是否有比切换到Jupyter笔记本以从其“单元”中受益更好的解决方案?

R kernel requires the file to be 'sourced' before any breakpoints can be activated - meaning you have to effectively execute the whole script in the console first. This only is acceptable if your scripts are either divided in short and well separated chunks and standalone functions, like a bag of tools. But what if your script consists of raw lines of code which are not working well together, and some even not working or bugged?
Is there a better solution than switching to Jupyter Notebook to benefit from its 'cells'?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

成熟的代价 2025-02-07 04:26:34

在rstudio中,您可以运行任意数量的代码行( link )并查看环境中的输出。

如果您要进行调试,也可以使用诸如browser(),debug()和debugonce()之类的功能。

In RStudio, you can run any number of lines of code (LINK) and view the output in the environment.

If you're debugging, you can also use functions such as browser(), debug(), and debugonce().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文