key<- with a factor mixes up factor levels, and loses the is.ordered property too.
Pretty simple example: > dt=data.table(x=factor(1:20,ordered=TRUE),y=rnorm(20)) > dt$x [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Levels: 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 14 < 15 < 16 < 17 < 18 < 19 < 20 > dt$x [1] 1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 5 6 7 8 9 Levels: 1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 5 6 7 8 9 With integers I could of course just leave them as integers instead of turning it into a factor, but the real case happening to me is I have upper cutoffs of buckets of a float variable, so I can't keep the simple numeric value for a key so it must be a factor. However, I want it to be ordered so that the factors still go lowest bucket to highest. I think this is a bug but I want confirmation before filing. -Chris _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
