How to modify unexported object in a package

后端 未结 1 551
借酒劲吻你
借酒劲吻你 2020-12-11 20:26

My package (let\'s call it A) depends on another package B. I need to modify a function f in B that has a bug that is causing my package to fail. The problem is

相关标签:
1条回答
  • 2020-12-11 20:35

    As it turns out, I only had to remove the unlockBinding, assign and lockBinding calls.

    bar <- function(x) x + 1
    assignInNamespace("C_rf", bar, ns="stats", pos="package:stats")
    
    stats:::C_rf
    # function(x) x + 1
    
    rf(3, 2, 2)
    #Error in .Call(C_rf, n, df1, df2) : 
    #  first argument must be a string (of length 1) or native symbol reference
    
    0 讨论(0)
提交回复
热议问题