Reputation: 109
I have this function here
person1$check_infection(person2)
person1 and person2 are R6 class objects, I have already rewritten the check_infection
method in S4, how do I write the above function in S4? I have already tried:
check_infection(person1, person2)
But it is not working as the function in R6 class. I had created the check_infection
generic as follows;
setGeneric('check_infection',
\(.Object, other) {
standardGeneric('check_infection')
})
setMethod('check_infection',
signature = 'Person',
\(.Object, other) {
if (.Object@S & other@I & runif(1) < beta / (N * contact_rate) * dt) {
.Object <- Infect(.Object)
}
return(.Object)
}
)
Upvotes: 0
Views: 63