Forcing a package's function to use user-provided function

前端 未结 2 1512
天命终不由人
天命终不由人 2021-01-18 04:41

I\'m running into a problem with the MNP package which I\'ve traced to an unfortunate call to deparse (whose maximum width is limited to 500 charac

2条回答
  •  醉话见心
    2021-01-18 05:23

    The functions fixInNamespace and assignInNamespace are provided to allow editing of existing functions. You could try ... but I will not since mucking with deparse looks too dangerous:

     assignInNamespace("deparse", 
                      function (expr, width.cutoff = 60L, backtick = mode(expr) %in% 
                   c("call", "expression", "(", "function"), control = c("keepInteger", 
                   "showAttributes", "keepNA"), nlines = -1L)  {
        ret <- .Internal(deparse(expr, width.cutoff, backtick, .deparseOpts(control), nlines))
        paste0(ret,collapse="")
                             }   , "base")
    

    There is an indication on the help page that the use of such functions has restrictions and I would not be surprised that such core function might have additional layers of protection. Since it works via side-effect, you should not need to assign the result.

提交回复
热议问题