Domanda

Se si trova un bug in un pacchetto, di solito è possibile correggere il problema con fixInNamespace, per esempio fixInNamespace("mean.default", "base").

Per i metodi S4, non sono sicuro di come farlo però. Il metodo che sto guardando è nel pacchetto gWidgetstcltk. Si può vedere il codice sorgente con

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

non riesco a trovare i metodi con fixInNamespace.

fixInNamespace(".svalue", "gWidgetstcltk")

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

Ho pensato setMethod potrebbe fare il trucco, ma

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"

Tutte le idee?

È stato utile?

Soluzione

Come circa il senso della vecchia scuola di ottenere la fonte, applicando la variazione e la ricostruzione?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top