0
영향을주지 않습니다,하지만 아무것도하지 :R S4 클래스는 멤버 함수 내가 목록에 요소를 추가하기로하는 S4 클래스 (프로그래밍 언어 R)의 멤버 함수를 정의
setClass("ListHolder",
representation(
.list = "list"
),
prototype(
.list = list()
))
setGeneric("add",
function(this,i) standardGeneric("add")
)
setMethod("add",
signature(this="ListHolder",i="numeric"),
definition = function(this,i){
k <- length([email protected])
[email protected][[k+1]] <- i
})
testListHolder <- function(){
lh <- new("ListHolder")
for(i in 1:10) add(lh,i)
print([email protected])
}
testListHolder()
이 뜻을 빈리스트를 출력한다. 여기서 무슨 일이 일어나고있는거야?
@Xiatao 루오 : 감사하는 데 도움이됩니다. – gcc