[R] Bug with curve?
Ben Bolker
bolker at ufl.edu
Fri Feb 1 15:03:15 CET 2008
Paul Smith <phhs80 <at> gmail.com> writes:
>
> Dear All,
>
> Take this code:
>
> > f <- function(x) exp(-x)*x-0.05
> > g <- function(x) 0
> > curve(f,0,5)
> > curve(g,add=T)
> Error in xy.coords(x, y) : 'x' and 'y' lengths differ
> >
>
> However, with
>
> g <- function(x) x-x
>
> no error is generated.
>
>
The first paragraph of "details" in the help page
says:
. 'x(t)' or 'expr' (with 'x' inside) must return a numeric of the same
length as the argument 't' or 'x'.
So no, technically this is not a bug.
The R idiom for adding a horizontal line to the plot is
abline(h=...)
cheers
Ben Bolker
More information about the R-help
mailing list