Skip to content
Prev 59284 / 398502 Next

changing (core) function argument defaults?

Berton Gunter <gunter.berton at gene.com> writes:
Actually, formals(mad)$constant<-2 will do the same. In either case,
you need to be careful to note that the environment of the function is
changed to the current frame. So if you redefine median(), this will
be picked up by your mad(), but not by stats::mad().
I'd expect that it works whenever the function has default arguments
to modify (.Primitive functions do not). The namespace mechanism only
ensures that you don't overwrite the original, and that packages
expecting to use the original can continue to do so.
Yes, R is not preventing users from shooting themselves in the foot,
nor preventing package writers from shooting users in the foot (as a
recent query involving [.factor showed).