What's the difference between setMethod(“$<-”) and set setReplaceMethod(“$”)?

前端 未结 1 1793
深忆病人
深忆病人 2021-01-04 20:07

Question

When programming in r with the s4 OOP system, when one have to use setReplaceMethod? I don\'t see what\'s the difference wit

相关标签:
1条回答
  • 2021-01-04 20:46

    Here's the definition of setReplaceMethod

    > setReplaceMethod
    function (f, ..., where = topenv(parent.frame())) 
    setMethod(paste0(f, "<-"), ..., where = where)
    <bytecode: 0x435e9d0>
    <environment: namespace:methods>
    

    It is pasting a "<-" on to the name, so is functionally equivalent to setMethod("$<-"). setReplaceMethod conveys more semantic meaning.

    0 讨论(0)
提交回复
热议问题