Skip to content

split.data.table does not respect factor ordering #2082

@MichaelChirico

Description

@MichaelChirico

Pretty self-explanatory. MWE:

DT = data.table(a = factor(c('a', 'b'), levels = c('b', 'a')))
split(DT, by = 'a', sorted = TRUE)
# $a
#    a
# 1: a

# $b
#    a
# 1: b
split(DT, f = DT$a, sorted = TRUE)
# $b
#    a
# 1: b

# $a
#    a
# 1: a
split.data.frame(DT, f = DT$a)
# $b
#    a
# 1: b

# $a
#    a
# 1: a

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