{"action":"created","issue":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/1507","labels_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1507/labels{/name}","comments_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1507/comments","events_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1507/events","html_url":"https://github.com/Rdatatable/data.table/issues/1507","id":128492777,"number":1507,"title":"Secondary key causes wrong results","user":{"login":"aushev","id":7884100,"avatar_url":"https://avatars.githubusercontent.com/u/7884100?v=3","gravatar_id":"","url":"https://api.github.com/users/aushev","html_url":"https://github.com/aushev","followers_url":"https://api.github.com/users/aushev/followers","following_url":"https://api.github.com/users/aushev/following{/other_user}","gists_url":"https://api.github.com/users/aushev/gists{/gist_id}","starred_url":"https://api.github.com/users/aushev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aushev/subscriptions","organizations_url":"https://api.github.com/users/aushev/orgs","repos_url":"https://api.github.com/users/aushev/repos","events_url":"https://api.github.com/users/aushev/events{/privacy}","received_events_url":"https://api.github.com/users/aushev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Rdatatable/data.table/labels/bug","name":"bug","color":"DF3A2C"},{"url":"https://api.github.com/repos/Rdatatable/data.table/labels/duplicate","name":"duplicate","color":"cccccc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-25T09:13:49Z","updated_at":"2016-01-25T17:12:46Z","closed_at":"2016-01-25T17:12:46Z","body":"(originally [asked at SO](http://stackoverflow.com/questions/34983209/problems-with-secondary-key-of-data-table))\r\n```\r\nmyDT <- data.table(ID=c('A','B','B'), val=c('check','check','a')) ; \r\nmyDT[val == \"check\"] ; \r\nmyDT[, val := ifelse(.N>1, '2', '1'), by = ID] ; \r\n#    ID val\r\n# 1:  A   1\r\n# 2:  B   2\r\n# 3:  B   2\r\nmyDT[val=='2']\r\n#    ID val\r\n# 1:  B   2\r\n```\r\n`val=='2'` is expected to give records 2 and 3 but only record 2 is found. Removing secondary key restores normal behavior:\r\n```\r\nset2key(myDT, NULL)\r\nmyDT[val=='2']\r\n#    ID val\r\n# 1:  B   2\r\n# 2:  B   2\r\n```"},"comment":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/comments/174589403","html_url":"https://github.com/Rdatatable/data.table/issues/1507#issuecomment-174589403","issue_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1507","id":174589403,"user":{"login":"arunsrinivasan","id":3102045,"avatar_url":"https://avatars.githubusercontent.com/u/3102045?v=3","gravatar_id":"","url":"https://api.github.com/users/arunsrinivasan","html_url":"https://github.com/arunsrinivasan","followers_url":"https://api.github.com/users/arunsrinivasan/followers","following_url":"https://api.github.com/users/arunsrinivasan/following{/other_user}","gists_url":"https://api.github.com/users/arunsrinivasan/gists{/gist_id}","starred_url":"https://api.github.com/users/arunsrinivasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arunsrinivasan/subscriptions","organizations_url":"https://api.github.com/users/arunsrinivasan/orgs","repos_url":"https://api.github.com/users/arunsrinivasan/repos","events_url":"https://api.github.com/users/arunsrinivasan/events{/privacy}","received_events_url":"https://api.github.com/users/arunsrinivasan/received_events","type":"User","site_admin":false},"created_at":"2016-01-25T17:12:46Z","updated_at":"2016-01-25T17:12:46Z","body":"Thanks, buy dup of #1479. If not, please write back."}}