I want to override some function in R, adding feature to them or modifying their behavior. For example I can't stand that for min, max, mean, sd and others the na.rm argument is false by default, or that if you run as.numeric on a factor it doesn't parse the level text but the level identifier.
So I want to rewrite it:
as.numeric <- function(x) {
if(is.numeric(x)) return(x)
if (is.factor(x)) x <- as.vector(x)
as.numeric(x)
}
Unfortunately this trigger an infinite recursion (of course). How do I solve this problem?