更新时间:2023-02-08 17:34:54
不确定它是否在找你
test <- setRefClass("test",
fields = list(
num1 = "numeric"
, num2 = function(){
print("hello")
2*.self$num1
}
),
methods = list(
initialize = function(num1 = 1){
num1 <<- num1
},
show = function(){
print(c(num1 = num1, num2 = num2))
}
)
)
> tt <- test()
> tt
[1] "hello;"
num1 num2
1 2
> tt$num1<-4
> tt
[1] "hello;"
num1 num2
4 8