2

I want to replace the default match() function with fmatch() which is faster. The following code works in R console

match<-fmatch

unlockBinding('match', baseenv())
assign("match", fastmatch::fmatch, envir = baseenv())

However, when I put either piece code in the Rprofile.site, it always gives an error. Does anyone have experience with this?

4

1 回答 1

2

将代码放入.First函数并将其保存在.Rdata用户目录中的默认工作区文件中。

.First <- function()
{
    ## Unless you unlock the binding, you can't change 
    ## an object in a locked namespace.
    unlockBinding('match', baseenv())
    assign("match", fastmatch::fmatch, envir = baseenv())
}
于 2013-07-23T16:55:23.537 回答