SCM

[#2375] head() and tail() don't allow negative values for n

View Trackers | Bugs | Download .csv | Monitor

Date:
2012-11-15 03:48
Priority:
3
State:
Closed
Submitted by:
Garrett See (gsee)
Assigned to:
Nobody (None)
Hardware:
None
Product:
None
Operating System:
None
Component:
None
Version:
None
Severity:
None
Resolution:
None
 
URL:
Summary:
head() and tail() don't allow negative values for n

Detailed description
I'm not sure whether this should be a bug report or a feature request...

R> set.seed(1)
R> DT <- data.table(LET=letters[1:5], NUM=rnorm(5))
R> tail(DT, -3)
LET NUM
1: NA NA
2: NA NA
3: NA NA
4: NA NA
5: e 0.3295078
R> tail(as.data.frame(DT), -3)
LET NUM
4 d 1.5952808
5 e 0.3295078

R> head(DT, -3)
Error in seq_len(min(n, nrow(x))) :
argument must be coercible to non-negative integer
R> head(as.data.frame(DT), -3)
LET NUM
1 a -0.6264538
2 b 0.1836433

Followup

Message
Date: 2013-09-08 12:18
Sender: Arun

This is fixed in commit 953 now. Thanks to Garrett for reporting.
Date: 2013-01-10 16:17
Sender: Matt Dowle

Solution could be just to remove head.data.table and tail.data.table. I can't see why I created them in the first place, since head.data.frame calls [ .... ah maybe that's why ... maybe [.data.table doesn't get called from inside base::tail.data.frame.
Date: 2012-11-15 09:07
Sender: Matt Dowle

Agreed, bug. Thanks, will fix.
Date: 2012-11-15 03:53
Sender: Garrett See

Sorry, obviously I meant tail.data.table and head.data.table

Attached Files:

Changes:

Field Old Value Date By
close_dateNone2013-09-08 12:21arun
status_idOpen2013-09-08 12:21arun
summarydata.table.tail and data.table.head do not allow negative values for n2012-11-15 12:37mdowle
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge