How to debug a call like getFields? I tried library(debug); mtrace(AB.setFields)
but nothing happend.
Besides there are some better ways to define AB.setFields?
AB.getFields<-function(){
return(list(name,var2))
}
AB.setFields<-function(fields){
namevar<-names(fields)
for(i in 1:length(fields)) do.call("<<-",list(namevar[i],fields[[i]]))
}
AB <- setRefClass("AB", fields=c(name="character",
var2="factor"),
methods=list(getFields=AB.getFields
,setFields=AB.setFields)
)
a<-AB(name="abc",var2=factor(LETTERS[1:3]))
a$getFields()
fields<-list(name="aaa",var2=factor(1:3))
a$setFields(fields)
a$getFields()
See Question&Answers more detail:os