可以让R打印更详细的错误信息吗? [英] Can you make R print more detailed error messages?

查看:145
本文介绍了可以让R打印更详细的错误信息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常对R的隐秘错误信息感到沮丧。在交互式会话中,我不是在谈论,我的意思是当你运行一个脚本。错误消息不打印行号,通常很难追踪违规行,错误原因(即使您可以找到位置)。



最近,我的R脚本失败了令人难以置信的洞察力的消息:执行停止。我通常追踪这种错误的方法是在整个脚本中放置大量的print语句 - 但这是一个痛苦。我有时必须在交互式会话中逐行地查看脚本,以查找错误。



有没有人有更好的解决方案来使R错误输出更多信息?



编辑:许多R调试工作用于交互式会话。我正在寻找通过Rscript运行的命令行脚本的帮助。当我发生错误时,我不在R会话的中间,我在bash shell。我不能运行traceback()

解决方案

尝试这篇文章中的一些建议:



你最喜欢的R调试技巧



具体来说, findLineNum() traceback() / setBreakpoint()


I've often been frustrated by R's cryptic error messages. I'm not talking about during an interactive session, I mean when you're running a script. Error messages don't print out line numbers, and it's often hard to trace the offending line, and the reason for the error (even if you can find the location).

Most recently my R script failed with the the incredibly insightful message: "Execution halted." The way I usually trace such errors is by putting a lot of print statements throughout the script -- but this is a pain. I sometimes have to go through the script line by line in an interactive session to find the error.

Does anyone have a better solution for how to make R error output more informative?

EDIT: Many R-debugging things work for interactive sessions. I'm looking for help on command-line scripts run through Rscript. I'm not in the middle of an R session when the error happens, I'm at the bash shell. I can't run "traceback()"

解决方案

Try some of the suggestions in this post:

What is your favorite R debugging trick?

Specifically, findLineNum() and traceback()/setBreakpoint().

这篇关于可以让R打印更详细的错误信息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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