[R] Plotting a function with curve()

Damon Wischik djw1005 at cam.ac.uk
Wed Jul 30 16:11:10 CEST 2003


Why does
> curve(function(y) y^2, from=0,to=1)
not work, whereas
> myf <- function(y) y^2
> curve(myf, from=0,to=1)
work?

For the former, I get the error message
Error in curve(function(y) y^2, from = 0, to = 1) : 
	'expr' must be a function or an expression containing 'x'

I'm using R1.7.0 under Windows XP.

Damon Wischik.




More information about the R-help mailing list