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

indices/key2 should return list #1589

Closed
jangorecki opened this issue Mar 12, 2016 · 1 comment
Closed

indices/key2 should return list #1589

jangorecki opened this issue Mar 12, 2016 · 1 comment
Assignees
Milestone

Comments

@jangorecki
Copy link
Member

There can be multiple indices on single data.table, each index can be set on multiple fields.
The most correct representation then is to return list of vectors.
Current behavior:

library(data.table)
dt = data.table(a=1,b=2,c=3,d=4)
setindexv(dt, "a")
setindexv(dt, c("a","b"))
setindexv(dt, c("b","a"))
setindexv(dt, c("d","c","a"))
indices(dt)
#[1] "a"       "a__b"    "b__a"    "d__c__a"

Expected

list("a", c("a","b"), c("b","a"), c("d","c","a"))
#[[1]]
#[1] "a"
#
#[[2]]
#[1] "a" "b"
#
#[[3]]
#[1] "b" "a"
#
#[[4]]
#[1] "d" "c" "a"

There could be an additional argument forcing to return a vector instead of list by collapsing column names.

sapply(list("a", c("a","b"), c("b","a"), c("d","c","a")), paste, collapse=",")
#[1] "a"     "a,b"   "b,a"   "d,c,a"
@mattdowle
Copy link
Member

Minor reopen to address: 3aa65e2#commitcomment-20075531

@mattdowle mattdowle reopened this Dec 5, 2016
@mattdowle mattdowle modified the milestones: Candidate, v1.10.2 Jan 31, 2017
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

3 participants