I'm using R's object system to create a modify objects with a number of functions. I am not sure the best way to do it for either S3 or S4 systems, or if there's any reason to prefer one over the other.
For example:
letters <- function(a) {
rtn <- list('a'=a)
class(rtn) <- 'letters'
rtn
}
b <- function(letobj, b) {
letobj$b <<- b
}
Will get the job done. But surely this isn't the preferred way to do this in S3. And what's the equivalent in S4? And which is preferred?