Pergunta

Se você encontrar um bug em um pacote, geralmente é possível corrigir o problema com fixInNamespace, por exemplo fixInNamespace("mean.default", "base").

Para os métodos S4, não tenho certeza de como fazê -lo. O método que estou olhando está no gWidgetstcltk pacote. Você pode ver o código -fonte com

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

Não consigo encontrar os métodos com fixInNamespace.

fixInNamespace(".svalue", "gWidgetstcltk")

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

Eu pensei setMethod pode fazer o truque, mas

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"

Alguma ideia?

Foi útil?

Solução

Que tal a maneira da velha escola de obter a fonte, aplicando a mudança e a reconstrução?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top