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

key argument is ignored within setDT if DT is already a data.table #1169

Closed
DavidArenburg opened this issue Jun 5, 2015 · 0 comments
Closed

Comments

@DavidArenburg
Copy link
Member

It's probably not a big deal, but sometimes you are not aware your object is already a data.table (like you've read it using fread) and this could be quite mind blowing until you realize what's going on

library(data.table)
DT <- data.table(A = 1:4, B = 5:8)
setDT(DT, key = "A")
key(DT)
## NULL

I think that a quick fix is just to add

 if (!is.null(key)) setkeyv(x, key)

after this line

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

No branches or pull requests

1 participant