0

パッケージにバグが見つかった場合、通常はfixInNamespace、たとえばで問題にパッチを当てることができfixInNamespace("mean.default", "base")ます。

S4メソッドの場合、どうすればよいかわかりません。私が見ている方法はgWidgetstcltkパッケージにあります。でソースコードを見ることができます

getMethod(".svalue", c("gTabletcltk", "guiWidgetsToolkittcltk"))

でメソッドが見つかりませんfixInNamespace

fixInNamespace(".svalue", "gWidgetstcltk")

Error in get(subx, envir = ns, inherits = FALSE) : 
  object '.svalue' not found

setMethod私はそのトリックを行うかもしれないと思ったが、

setMethod(".svalue", c("gTabletcltk", "guiWidgetsToolkittcltk"),
  definition = function (obj, toolkit, index = NULL, drop = NULL, ...) 
  {
      widget = getWidget(obj)
      sel <- unlist(strsplit(tclvalue(tcl(widget, "selection")), 
          " "))
      if (length(sel) == 0) {
          return(NA)
      }
      theChildren <- .allChildren(widget)
      indices <- sapply(sel, function(i) match(i, theChildren))
      inds <- which(visible(obj))[indices]
      if (!is.null(index) && index == TRUE) {
          return(inds)
      }
      if (missing(drop) || is.null(drop)) 
          drop = TRUE
      chosencol <- tag(obj, "chosencol")
      if (drop) 
          return(obj[inds, chosencol, drop = drop])
      else return(obj[inds, ])
  },
  where = "package:gWidgetstcltk"  
)

Error in setMethod(".svalue", c("gTabletcltk", "guiWidgetsToolkittcltk"),  : 
  the environment "gWidgetstcltk" is locked; cannot assign methods for function ".svalue"

何か案は?

4

2 に答える 2

1

ソースを取得し、変更を適用して再構築する昔ながらの方法はどうですか?

于 2010-05-14T15:34:44.487 に答える