Reputation: 171
I want to implement the length()
function in R for S4 class instances. I would have a class:
setClass("A", slots = c(ll = "list"))
Then, I want to create an instance inst
of class A and call length(inst)
.
My previous attempts have failed and so far I could only find a way to do this for S3 classes. (Like the Formula
package does here.)
Upvotes: 0
Views: 112
Reputation: 399
Assuming you just want your length()
method to delegate to the slot "ll".
setMethod("length", signature = "A", definition = function(x) length(x@ll))
Upvotes: 2