From maechler at stat.math.ethz.ch  Sat Feb  4 17:27:54 2017
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Sat, 4 Feb 2017 17:27:54 +0100
Subject: [Rd] Lack of 'seq_len' in 'head' in 'stopifnot'
In-Reply-To: <2134429091.881467.1486203513831@mail.yahoo.com>
References: <2134429091.881467.1486203513831.ref@mail.yahoo.com>
	<2134429091.881467.1486203513831@mail.yahoo.com>
Message-ID: <22678.266.503476.429238@stat.math.ethz.ch>

>>>>> Suharto Anggono Suharto Anggono via R-devel <r-devel at r-project.org>
>>>>>     on Sat, 4 Feb 2017 10:18:33 +0000 writes:

    > Function 'stopifnot' in R devel r72104 has this.
    >   head <- function(x, n = 6L) ## basically utils:::head.default()
    >         x[if(n < 0L) max(length(x) + n, 0L) else min(n, length(x))]

    > If definition like utils:::head.default is intended, the index of 'x' should be wrapped in seq_len(...):
    > x[seq_len(...)]

You are right... that was "lost in translation" .

As  seq_len(1) is 1   and that seems to have been the only case
much exercised, nobody seems to have noticed the problem till
now ((this assumes people *would* report it if they noticed.
      Yes, "hope dies last"  ;-))

Thank you, this is amended now.
Martin



[Rd] Lack of 'seq_len' in 'head' in 'stopifnot'
Martin Maechler