head和tail不将负数作为data.table的参数?

col*_*ang 2 r data.table

为什么headtail工作方式不同data.table?它是按设计的吗?

> head(data.frame(x=1:10), -2)
  x
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
> head(data.table(x=1:10), -2)
Error in seq_len(min(n, nrow(x))) : 
  argument must be coercible to non-negative integer
> tail(data.table(x=1:10), -2)
    x
1: NA
2: NA
3: NA
4: 10
> tail(data.frame(x=1:10), -2)
    x
3   3
4   4
5   5
6   6
7   7
8   8
9   9
10 10
Run Code Online (Sandbox Code Playgroud)

Aru*_*run 8

是的,这是之前报道的,#2375.现在已在v1.8.11修复.来自新闻:

head()tail()正确处理现在负"N"值,#2375.感谢Garrett See的报道.此外,它会导致错误length(n) != 1.测试补充说.