Skip to content

Also switch to forder on subsetted ordering in i #1921

@MichaelChirico

Description

@MichaelChirico

If we want to get the top five entries of a column, I guess the canonical approach is:

set.seed(45L)
DT = data.table(A=sample(3, 10, TRUE), 
         B=sample(letters[1:3], 10, TRUE), C=sample(10))

DT[order(C), C[1:5]]

But I've found in more general scenarios (for example, subsetting on the top five of C then performing some operations on other columns) the following approach to be useful :

DT[order(C)[1:5], B]

However, this approach kills forder detection:

DT[order(C)[1:5], B, verbose = TRUE]

I guess it's easy to detect this and do forder and then subset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions