【发布时间】:2020-09-09 06:04:58
【问题描述】:
我不是 S4 方面的专家,但在获得一些在线帮助后开始。以下代码工作正常,现在我想设置默认值 alpha=0.05 如果调用中缺少 alpha。
setClass(Class = "Test",
representation = representation(
data = "data.frame",
rep = "numeric",
MSE = "numeric",
alpha = "numeric"
)
)
setMethod(
f = "initialize",
signature = "Test",
definition = function(.Object, data, rep, MSE, alpha)
{
.Object@data <- data
.Object@rep <- rep
.Object@MSE <- MSE
.Object@alpha <- alpha
return(.Object)
}
)
new(Class= "Test", data = Data, rep = 4, MSE = 1.8, alpha = 0.1)
【问题讨论】: