Paul Smith wrote:
>> f <- function(x) exp(-x)*x-0.05
>> g <- function(x) 0
>> Error in xy.coords(x, y) : 'x' and 'y' lengths differ
> However, with
> g <- function(x) x-x
> no error is generated.
> Is this a bug?
No; simplify it:
g1 <- function(x) 0
g2 <- function(x) x - x
g1(anything) will return (scalar) 0
g2(scalar) will return (scalar) 0, g2(vector) will return (vector) 0, g2(matrix) will return (matrix) 0.
So, in your original problem, f and (first) g have different behaviours.
Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Archive generated by hypermail 2.2.0, at Fri 01 Feb 2008 - 14:30:10 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