9

パッケージ化された関数の本体を一時的に編集するにはfunc、 を頻繁に使用しますtrace(func, edit=TRUE)funcただし、何らかの理由で、 isの場合、R はこれを実行できません[.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.0data.table_1.8.8ていますが、 setoptions(editor="emacs")options(editor="notepad")使用しても、R GUI の既定のエディターを使用しても同じエラーが発生します。

4

1 に答える 1