Consider the following small hunk of code using S4 objects.
afun <- function() {}
Obj <- setObject("Obj",slots(val=numeric))
setGeneric("getVal", function(o) standardGeneric("getVal"))
setGeneric("getVal<-", function(o,value) standardGeneric("getVal<-"))
setMethod("getVal","Obj", function(o) o@val)
setMethod("getVal<-", "Obj", function(o,value) {
o@val <- as.numeric(value)
o})
incVal <- function (o, inc) {
getVal(o) <- getVal(o) + inc
o
}
If I open this in a window in R Studio, and press the TOC button (next to the source button), I only see afun
and incVal
listsed. I don't see Obj
, getVal
, getVal<-
or any of the methods. It would be nice if I could see methods, generics and objects and not just the regular functions.