I am running Rmpi and MPICH2 to do parallelization in a Windows 7 machine.
I am only using my PC's cores. Parallelization for standard R code works
fine. For S4 code I am having the following problem:
Let us say I have a class A and a subclasses B and C (both B and C
"contains" A). I declared a method
setGeneric(
name = "superClassMethod",
def = function(object) {standardGeneric("superClassMethod")}
)
setMethod(
f = "superClassMethod",
signature = "A",
definition = function(object) {
# Some code here
}
)
At some point I call function paralapply (similar to parLapply) in this way
my.list <- paralapply(some.other.list, superClassMethod, papply_commondata
= envir.vars)
Then I get an error message as follows:
Error message: Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "superClassMethod",
for
signature "B"
Error in paralapply(some.other.list, superClassMethod, papply_commondata
envir.vars)
On the other hand, if I redefine the method for classes B and C as follows:
setMethod(
f = "superClassMethod",
signature = "B",
definition = function(object) {
# Some code here
}
)
setMethod(
f = "superClassMethod",
signature = "C",
definition = function(object) {
# Some code here
}
)
Obviously this goes against the idea of polymorphism.
How can I solve this problem?
Thanks for any help.
Fernando Saldanha
[[alternative HTML version deleted]]