Cómo arreglar un método S4 en un paquete de I?
Pregunta
Si usted encuentra un error en un paquete, por lo general es posible arreglar el problema con fixInNamespace
, por ejemplo, fixInNamespace("mean.default", "base")
.
Para los métodos S4, no estoy seguro de cómo hacerlo sin embargo. El método que estoy viendo es en el paquete gWidgetstcltk
. Se puede ver el código fuente con
getMethod(".svalue", c("gTabletcltk", "guiWidgetsToolkittcltk"))
No se puede encontrar los métodos con fixInNamespace
.
fixInNamespace(".svalue", "gWidgetstcltk")
Error in get(subx, envir = ns, inherits = FALSE) :
object '.svalue' not found
pensé setMethod
puede hacer el truco, pero
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"
¿Alguna idea?
Solución
¿Qué hay de la manera de la vieja escuela de conseguir la fuente, la aplicación del cambio y la reconstrucción?
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow