[R] curve

Duncan Murdoch murdoch at stats.uwo.ca
Thu Apr 15 15:28:40 CEST 2010


On 14/04/2010 4:59 PM, Dwayne Blind wrote:
> Dear R users,
>
> How can I use "curve" with a function of two variables ?
>   

See Ben Bolker's reply if you want to plot a surface.  If you want to 
plot a curve by holding one of the two variables fixed, just set it to a 
constant value, and use "x" as the other variable, e.g.

f <- function(x, y) { x^2 + y^2 }

curve(f(x, 2), from= .... )

curve(f(3, x), from= .... )

or wrap the function in a one variable function if you want to follow 
some complicated path, e.g.

curve(function(t) f(t, t^2), from=....)

Duncan Murdoch



More information about the R-help mailing list