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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -