Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-Forge #4856] rbind, rbindlist, and merge don't preserve "ordered" factor columns; convert them to "factor" #359

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 0 comments

Comments

@arunsrinivasan
Copy link
Member

Submitted by: Arun ; Assigned to: Eduard Antonyan; R-Forge link

dt1 <- data.table(x=1:5, y=factor(letters[1:5], ordered=TRUE), z=factor(letters[1:5]))
dt2 <- data.table(x=6:10, y=sample(letters, 5), z=sample(letters, 5))

dt1$y is an ordered factor here. Doing:

sapply(rbind(dt1, dt2) , class) gives:
x y z
"integer" "factor" "factor"

sapply(rbindlist(list(dt1, dt2)) , class) gives:
x y z
"integer" "factor" "factor"


After an internal discussion, rbinding ordered with any not-ordered class should result in an ordered column (with the given ordered order and some, maybe first come first serve, order for the unordered part). ordered+ordered should result in ordered iff the orders are compatible and should result in a factor + a warning if the orders are not compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant