I am trying to create a method for the class "subject" using the Generic method "summary". However, I get an error message. Could you help me understand what I am doing wrong and how to correct it? Thank you.
setGeneric("summary")
setMethod("summary",
c(x = "subject"),
function(x){"This is summary for subject class"})
The error message is the following:
Error in match.call(definition, call, expand.dots, envir) :
unused argument (x = c("subject", ""))
I have used the setMethod to create a method for the class "subject" using the Generic method "print" as follows:
setMethod("print",
c(x = "subject"),
function(x){
if (length(x$id) > 0){
paste0("Subject ID: ", unique(x$id))}
else {"NULL"}
})
The aforementioned code is executed without errors. I can not understand what is the difference between the two cases.