我定义了一个类(S4)并将其命名为LD
。对于这个类,我指定了一个方法,我给它命名为subject
。
setClass("LD",
slots = list(id = "numeric",
age = "numeric",
gender = "character"))
setGeneric("subject", function(x){
standardGeneric("subject")
})
setMethod("subject",
signature(x = "LD", n ="numeric"),
function(x, n){
if(sum(x@id != n)==0){
return(NULL)
} else {
return(paste0("Subject ID: ", n))
}
})
我收到以下错误消息:
Error in match.call(definition, call, expand.dots, envir) :
unused argument (n = c("numeric", ""))