Suharto Anggono Suharto Anggono
2017-Feb-04 10:18 UTC
[Rd] Lack of 'seq_len' in 'head' in 'stopifnot'
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(...)]
>>>>> 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