1
ReferenceClass 방법에서 data.table의 사본을 반환 :나는 ReferenceClass의 방법에서 <code>data.table</code>의 사본을 반환하려고
을 :dummy$getTab()
를 호출, 그러나
dummy <- setRefClass(
"dummy",
fields = list(
dt = "data.table"
),
methods = list(
initialize = function(df){
if(!missing(df)){
dt <<- data.table(df , key = "a")
}
},
getTab = function(ix){
return(copy(dt[ ix, ]))
}
)
)
내가 이해하지 못하는 오류를 산출
d <- dummy$new(data.frame(a = 1:10, b = 1:10))
d$getTab(2:5)
Error in if (shallow) assign(field, get(field, envir = selfEnv), envir = vEnv) else { :
argument is not interpretable as logical
In addition: Warning message:
In if (shallow) assign(field, get(field, envir = selfEnv), envir = vEnv) else { :
the condition has length > 1 and only the first element will be used
실마리가 없습니다. 의미와 의미는 무엇입니까? 또한 다음 두 절차가 문제없이 작동합니다.
copy(d$dt[ 2:5 ])
mycopy <- function(dt, ix) {
return(copy(dt[ ix, ]))
}
mycopy(d$dt, 2:5)
도움이 되었습니까?