Using sd as a generic function in R
If I a have a class called foo , then it is straightforward to overload the summary function summary.foo = function(x, ...) print("bar") However this technique does not work with the sd function, that is > bar = createFooClass() > sd.foo = function(x, ...) print("Hi") > sd(bar) error: is.atomic(x) is not TRUE What is the correct way of overloading this function? You can hijack any non-generic function, make it (S3) generic and set the original version to be the default version. For example: ## make an S3 generic for sd sd <- function(x, ...) UseMethod("sd") ## take the usual definition of sd,