Accept an R function with diag.function.