为什么trace(...,edit = TRUE)不起作用要临时编辑封装函数func
的正文,我经常使用trace(func, edit=TRUE)
。出于某种原因,不过,R是不是让我做这件事的时候func
是[.data.table
:当... = [.data.table
## Note: In this and the other cases below, once an editor pops up, I save and
## and then exit without making any edits to the function. The commented-out
## message below each call to trace() is what is then printed to my R console.
trace("[.data.table", where=data.table, edit=TRUE)
# Error in .makeTracedFunction(def, tracer, exit, at, print, doEdit) :
# the editing in trace() can only change the body of the function, not
# the arguments or defaults
问题:什么可能导致这个错误?还有哪些其他功能也会触发它?对于这样的功能,是否有一些替代解决方法可以让我编辑它们?
FWIW,这似乎并没有为与功能的一些一般问题在data.table的名字空间(例如参见下面#1
)也不是与一般的子集的方法的问题(参见例如下面#2
)。
## (#1)
trace("within.data.table", where=data.table, edit=TRUE)
# Tracing function "within.data.table" as seen from package "data.table"
# [1] "within.data.table"
## (#2)
trace("[.Date", edit=TRUE)
# Tracing function "[.Date" in package "base"
# [1] "[.Date"
我的Windows XP计算机上运行R-3.0.0
和data.table_1.8.8
,并得到了同样的错误我是使用设置options(editor="emacs")
,options(editor="notepad")
或使用R GUI的默认编辑器。
它为我在2.15.3与data.table_1.8.6,Windows 7的 – 2013-04-10 17:02:10
不过,我得到了同样的错误升级到1.8.8后, 。 – 2013-04-10 17:10:49
@MatthewPlourde - 谢谢!这真的有助于缩小问题范围。 – 2013-04-10 17:12:06