R脚本行号错误? [英] R script line numbers at error?

查看:162
本文介绍了R脚本行号错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一年前发现了帖子,而我使用 R版本2.11.1(2010-05-31),但是仍然收到没有行号的错误消息。

I found this post from a year ago, and I'm using R version 2.11.1 (2010-05-31), but still getting error messages without line numbers.

任何解决方案?

推荐答案

给出的答案仍然有效。从脚本中返回行号并不是直接的,但是R可以给你更多关于错误发现位置的信息。

The answers given there are still valid. Returning line numbers from a script ain't that straight-forward, but R can give you a lot more information on where the error can be found.

你可以使用将信息保存在文件中的错误选项,例如:

You could use the error options to save the info in a file, for example :

options(error = quote({
  sink(file="error.txt");
  dump.frames();
  print(attr(last.dump,"error.message"));
  traceback();
  sink();
  q()}))

函数findLineNum如果您有文件的名称可用的位置使用。如果您有错误消息,您可以执行以下操作:

The function findLineNum() could be used if you have the name of the file somewhere available. If you have the error message, you could do something like :

dump.frames()
x <- attr(last.dump,"error.message")
ll <- gsub("Error in (.*) : .*","\\1",x)
lln <- findLineNum(srcfile,ll)

这篇关于R脚本行号错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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