Along the line of @Hadley’s solution, but using the environment of the namespace, how about:
environment(myfun) <- asNamespace('stats')
Along the line of @Hadley’s solution, but using the environment of the namespace, how about:
environment(myfun) <- asNamespace('stats')