Re: [R] Bug with curve?

From: Ben Bolker <bolker_at_ufl.edu>
Date: Fri, 1 Feb 2008 14:03:15 +0000 (UTC)

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 01 Feb 2008 - 14:07:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Feb 2008 - 15:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive