Re: [Rd] Lack of 'seq_len' in 'head' in 'stopifnot'

2017-02-04 Thread Martin Maechler
> Suharto Anggono Suharto Anggono via R-devel 
> on Sat, 4 Feb 2017 10:18:33 + 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

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


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

2017-02-04 Thread Suharto Anggono Suharto Anggono via R-devel
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(...)]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel