I have written the R function myplot() which draws a curve corresponding to the supplied function FUN over the interval [-10, 10].
myplot <- function(FUN)
{
curve(FUN(x), xlim = c(-10, 10))
}
For example
myplot(FUN = dnorm)
gives
How can I add arguments to FUN? For example, let's say I want to plot the normal density with mean 5.
Following @akrun's comment, I can do something like that:
myplot <- function(FUN, ...)
{
args <- list(...)
curve(FUN(x, unlist(args)), xlim = c(-10, 10))
}
myplot(dnorm, mean = 5)
But then
> myplot(FUN = dnorm)
Error in FUN(x, unlist(args)) :
Argument non numérique pour une fonction mathématique
Also, myplot(FUN = dnorm, mean = 5, sd = 2) does not give the expected picture...

dots <- list(...); curve(FUN(x, unlist(dots)), xlim = c(-10, 10))