Skip to content

keyby with multiple keys with same name do not respect ordering of factors #1334

Closed

Description

@caneff

This is a very edge case with an easy workaround but I ran into it using cut on multiple variables in a key.

d <- data.table(x=ordered(rep(1:3,each=5)),y=ordered(rep(c("B","A","C"),5),levels=c("B","A","C")),z=1:15)
d[, mean(z), keyby=.(x,y)] # Ordering is respected
d[, mean(z), keyby=.(I(x), I(y))] # Ordering of the y column is not respected
d[, mean(z), keyby=.(a=I(x), b=I(y))] # Ordering of the y column respected again now that the column names are different.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions