[R] Accidentally replacing core R functions
Duncan Murdoch
murdoch.duncan at gmail.com
Sat Aug 3 11:34:28 CEST 2013
On 13-08-03 3:47 AM, Rguy wrote:
> I sometimes find that a function I have defined has the same name as an R
> core function. In most cases I have no desire to redefine the core R
> function and would prefer to give my function a different name.
>
> The problem is that R lets users redefine its core functions without any
> warning. Is there a way to cause R to generate a warning if a core function
> is being redefined?
>
> To give an actual example, in my personal library of functions I have a
> 'seek' function. I recently noticed that seek(con, ...) is part of base R.
> Now I plan to rename my personal 'seek' function but would have benefited
> from a warning when I first created this function.
You haven't redefined the core function, you have created a new function
that masks it. The original is still available.
The solution is to keep your personal library of functions small so
masking is obvious or not a problem, or to put it into a package. If
you put your personal library into a package, you'll be warned if your
package masks a base function.
Duncan Murdoch
More information about the R-help
mailing list