Make `==` a generic funciton in R -
i make ==
generic function.
when run: setgeneric("==")
, definition not appear change:
> `==` function (e1, e2) .primitive("==") > setgeneric("==") [1] "==" > `==` function (e1, e2) .primitive("==")
and when call setgeneric("`==`")
, following error:
> setgeneric("`==`") error in setgeneric("`==`") : must supply function skeleton ‘`==`’, explicitly or via existing function
i can define ==
function with:
`==` <- function(x,y) 42;
and can use setgeneric
on it. i'd have put body of original ==
there, seems clunky.
so there way make ==
generic in s4?
thanks mrflick's response:
it turns out ==
generic (implement in c). don't need call setgeneric
.
rather, can use setmethod
.
setmethod("==", c(e1="class1",e2="class2"), funciton(e1,e2) { .... })
Comments
Post a Comment