头和尾不使用负数作为data.table的参数? [英] head and tail doesn't take negative number as argument for data.table?

查看:486
本文介绍了头和尾不使用负数作为data.table的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

data.table c>?是设计吗?

Why head and tail work differently for data.table? Is it by design?

> 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


推荐答案

是,之前报告过,#2375 。现在已在 v1.8.11 中修正。从新闻

Yes, this was reported before, #2375. This is now fixed in v1.8.11. From NEWS:


head() tail()现在正确处理负'n'值,#2375。感谢Garrett See报告。此外,当 length(n)!= 1 时会导致错误。已添加测试。

head() and tail() handle negative 'n' values correctly now, #2375. Thanks to Garrett See for reporting. Also it results in an error when length(n) != 1. Tests added.

这篇关于头和尾不使用负数作为data.table的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆