从命令提示中查找R脚本时出错时显示行号
考虑以下从命令提示中查找R脚本时出错时显示行号,r,debugging,R,Debugging,考虑以下R文件(C:\Users\Pedro\Desktop\test.R): 然后正确打印行号并显示错误消息: 但是,如果通过执行以下操作从windows cmd提示符运行上述命令: R --slave --restore --no-save -e "options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R')" 那么就没有行号了: 因此,我的问题是:当从windows cmd提示符获取R文件
R
文件(C:\Users\Pedro\Desktop\test.R
):
然后正确打印行号并显示错误消息:
但是,如果通过执行以下操作从windows cmd提示符运行上述命令:
R --slave --restore --no-save -e "options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R')"
那么就没有行号了:
因此,我的问题是:当从windows cmd提示符获取R文件时,如何在错误消息中获取行号?使用
keep.source=TRUE
似乎可以解决我的问题:
options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R', keep.source=TRUE)
R --slave --restore --no-save -e "options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R')"
options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R', keep.source=TRUE)