Re: [Rd] bugs in head() and tail()

2019-03-28 Thread Barry Rowlingson
On Wed, Mar 27, 2019 at 1:52 AM Abs Spurdle wrote: > > In the case of head.default(), it assumes that the object is a vector, or > something similar. > No it doesn't. It assumes (ultimately) that x[seq_len(n)] is the correct way to generate a "head" of something. Which is reasonable. That's depe

Re: [Rd] bugs in head() and tail()

2019-03-26 Thread Abs Spurdle
> so instead of hitting utils:::head.function, it hits utils:::head.default, which uses [ on the argument, causing the error. I've thought about this some more. And I still think that this is a bug. If a generic has a default method, then that default method should be guaranteed to work. Or at le

Re: [Rd] bugs in head() and tail()

2019-03-25 Thread Gabriel Becker
Hi Abs, This is because the class is "f", not c("f", "function") in your second example. S3 method dispatch is doing what you (unintentionally, I presume) asked it to do. The S3 method which allows head to take functions is utils:::head.function. S3 can only be expected to understand inheritance

[Rd] bugs in head() and tail()

2019-03-25 Thread Abs Spurdle
(Using R 3.5.3). I found bugs in head() and tail(). The following works: > f = function () 1 > head (f) 1 function () 2 1 However, the following does not: > class (f) = "f" > head (f) Error in x[seq_len(n)] : object of type 'closure' is not subsettable [[alternative HTML version delet