rk.replace.function {rkward}R Documentation

Replace a function inside its package environment / namespace

Usage

rk.replace.function(functionname, environment, replacement, copy.formals=TRUE)

Arguments

functionname name of the function to be replaced (character).
environment package environment or namespace, where replacment should be done.
replacement the replacement. This should be a function.
copy.formals logical; whether to copy the formals from the original function.

Details

rk.replace.function can be used to replace a function inside a different package / namespace. It is mainly intended for internal usage inside rkward, e.g. to replace menu and select.list with appropriate GUI implementations.

The original function is assigned to the environment of the rkward package, as ".rk.FUNCTIONAME.default", and can be referred to from the replacement. WARNING: This mechansim does not support several subsequent replacments of the same function.

WARNING: This function can be used to alter - and disrupt - internal functions in arbitrary ways. You better know what you are doing.

WARNING: Does not work well on generics!

Value

Returns NULL, invisibly, unconditionally.

Author(s)

Thomas Friedrichsmeier rkward-devel@lists.sourceforge.net

See Also

assignInNamespace, debug

Examples

## Not run
rk.replace.function ("history", as.environment ("package:utils"),
  function () {
    cat ("This is what you typed:\n")
    eval (body (.rk.history.default))
  })
## End not run

[Package rkward version 0.5.5 Index]