{"action":"created","issue":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/954","labels_url":"https://api.github.com/repos/Rdatatable/data.table/issues/954/labels{/name}","comments_url":"https://api.github.com/repos/Rdatatable/data.table/issues/954/comments","events_url":"https://api.github.com/repos/Rdatatable/data.table/issues/954/events","html_url":"https://github.com/Rdatatable/data.table/issues/954","id":48932916,"number":954,"title":"data.table column creation with `:=` and double indexing","user":{"login":"hraoyama","id":9772920,"avatar_url":"https://avatars.githubusercontent.com/u/9772920?v=3","gravatar_id":"","url":"https://api.github.com/users/hraoyama","html_url":"https://github.com/hraoyama","followers_url":"https://api.github.com/users/hraoyama/followers","following_url":"https://api.github.com/users/hraoyama/following{/other_user}","gists_url":"https://api.github.com/users/hraoyama/gists{/gist_id}","starred_url":"https://api.github.com/users/hraoyama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hraoyama/subscriptions","organizations_url":"https://api.github.com/users/hraoyama/orgs","repos_url":"https://api.github.com/users/hraoyama/repos","events_url":"https://api.github.com/users/hraoyama/events{/privacy}","received_events_url":"https://api.github.com/users/hraoyama/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Rdatatable/data.table/labels/feature%20request","name":"feature request","color":"734A82"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-11-15T21:15:15Z","updated_at":"2015-01-28T03:14:30Z","closed_at":"2015-01-28T03:14:30Z","body":"Refer to : [stackoverflow issue](http://stackoverflow.com/questions/26949827/data-table-column-creation-with-and-double-indexing?noredirect=1#comment42441244_26949827)\r\n\r\nI am processing a data.table instance and looking to create an extra column using := this worked fine until I did some double indexing.\r\n\r\nTo duplicate:\r\n\r\n```R\r\nexample_data$MONTH = apply(example_data,1, function(x) { strsplit(as.character(x[[\"V3\"]]),\"\\\\.\")[[1]][1]})\r\n```\r\na natural syntax is:\r\n\r\n```R\r\nexample_data[,MONTH:=strsplit(as.character(V3),\"\\\\.\")[[1]][1]]\r\n```\r\n\r\nHowever the double indexing is not being interpreted as I intended, because it is changing all values to the outcome of the first row. Removing the indexing does perform the correct operation (just not extracting and placing the data in the right place)\r\n\r\nAs Arun says:\r\n\r\n> *You need the same apply (or better sapply) to get the first element of each list. But we should provide a function to do this conveniently. Could you please file an issue here? –  Arun 1 hour ago*\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Rdatatable/data.table/issues/comments/71774167","html_url":"https://github.com/Rdatatable/data.table/issues/954#issuecomment-71774167","issue_url":"https://api.github.com/repos/Rdatatable/data.table/issues/954","id":71774167,"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":"2015-01-28T03:14:30Z","updated_at":"2015-01-28T03:14:30Z","body":"Implemented `transpose()` and `tstrsplit()` in commit d5e49fbd77327968095219a2905ee5be68e56a6b.\r\nAlso updated [the relevant SO post](http://stackoverflow.com/a/28183977/559784).\r\n"}}