{"action":"opened","number":1839,"pull_request":{"url":"https://api.github.com/repos/Rdatatable/data.table/pulls/1839","id":83912083,"html_url":"https://github.com/Rdatatable/data.table/pull/1839","diff_url":"https://github.com/Rdatatable/data.table/pull/1839.diff","patch_url":"https://github.com/Rdatatable/data.table/pull/1839.patch","issue_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1839","number":1839,"state":"open","locked":false,"title":"Closes #1836; adds - method for IDate, with substantial speed-up","user":{"login":"MichaelChirico","id":7606389,"avatar_url":"https://avatars.githubusercontent.com/u/7606389?v=3","gravatar_id":"","url":"https://api.github.com/users/MichaelChirico","html_url":"https://github.com/MichaelChirico","followers_url":"https://api.github.com/users/MichaelChirico/followers","following_url":"https://api.github.com/users/MichaelChirico/following{/other_user}","gists_url":"https://api.github.com/users/MichaelChirico/gists{/gist_id}","starred_url":"https://api.github.com/users/MichaelChirico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichaelChirico/subscriptions","organizations_url":"https://api.github.com/users/MichaelChirico/orgs","repos_url":"https://api.github.com/users/MichaelChirico/repos","events_url":"https://api.github.com/users/MichaelChirico/events{/privacy}","received_events_url":"https://api.github.com/users/MichaelChirico/received_events","type":"User","site_admin":false},"body":"We can skirt around the `as.POSIXct.IDate` sluggishness vs. precision tradeoff and still solve the molasses-like subtraction of `IDate`s.\r\n\r\nRunning @franknarf1 's example on this branch, I find we're now _faster_ than subtracting `Date`s (which should be the case in the first place since we're subtracting integers -- but more so since I tweaked the approach of `-.Date` to be a bit faster).\r\n\r\nOne potential funkiness is that I'm secretly supplying an `integer` vector to become a `difftime` object, which everywhere else would have a `numeric` vector underneath... not sure how un-kosher that is. Time to create `Idifftime`?\r\n\r\nTimings on my current crappy machine:\r\n```\r\nlibrary(data.table)\r\nset.seed(1)\r\nid <- 1:1e4\r\ndate_samp <- seq(as.IDate(\"2010-01-01\"),as.IDate(\"2011-01-01\"),\"day\")\r\nn_samp <- 5e7\r\nDT <- data.table(\r\n  id = sample(id,size = n_samp, replace=TRUE),\r\n  date_1 = sample(date_samp,size = n_samp, replace=TRUE)\r\n)\r\nsetkey(DT,id,date_1)\r\n\r\n# also with vanilla dates\r\nDT[, dt := as.Date(date_1)]\r\n\r\nsystem.time(DT[, diff := date_1 - shift(date_1), by=id])\r\n#    user  system elapsed \r\n#   1.775   0.168   1.945 \r\n\r\nsystem.time(DT[, diff2 := dt - shift(dt), by=id])\r\n#    user  system elapsed \r\n#   3.954   0.213   4.173 \r\n```","created_at":"2016-09-04T03:07:11Z","updated_at":"2016-09-04T03:07:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Rdatatable/data.table/pulls/1839/commits","review_comments_url":"https://api.github.com/repos/Rdatatable/data.table/pulls/1839/comments","review_comment_url":"https://api.github.com/repos/Rdatatable/data.table/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Rdatatable/data.table/issues/1839/comments","statuses_url":"https://api.github.com/repos/Rdatatable/data.table/statuses/bbaf7c600bdfbe612b0d0e3c44019ed6cce140cd","head":{"label":"MichaelChirico:IDateminus","ref":"IDateminus","sha":"bbaf7c600bdfbe612b0d0e3c44019ed6cce140cd","user":{"login":"MichaelChirico","id":7606389,"avatar_url":"https://avatars.githubusercontent.com/u/7606389?v=3","gravatar_id":"","url":"https://api.github.com/users/MichaelChirico","html_url":"https://github.com/MichaelChirico","followers_url":"https://api.github.com/users/MichaelChirico/followers","following_url":"https://api.github.com/users/MichaelChirico/following{/other_user}","gists_url":"https://api.github.com/users/MichaelChirico/gists{/gist_id}","starred_url":"https://api.github.com/users/MichaelChirico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichaelChirico/subscriptions","organizations_url":"https://api.github.com/users/MichaelChirico/orgs","repos_url":"https://api.github.com/users/MichaelChirico/repos","events_url":"https://api.github.com/users/MichaelChirico/events{/privacy}","received_events_url":"https://api.github.com/users/MichaelChirico/received_events","type":"User","site_admin":false},"repo":{"id":42277116,"name":"data.table","full_name":"MichaelChirico/data.table","owner":{"login":"MichaelChirico","id":7606389,"avatar_url":"https://avatars.githubusercontent.com/u/7606389?v=3","gravatar_id":"","url":"https://api.github.com/users/MichaelChirico","html_url":"https://github.com/MichaelChirico","followers_url":"https://api.github.com/users/MichaelChirico/followers","following_url":"https://api.github.com/users/MichaelChirico/following{/other_user}","gists_url":"https://api.github.com/users/MichaelChirico/gists{/gist_id}","starred_url":"https://api.github.com/users/MichaelChirico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichaelChirico/subscriptions","organizations_url":"https://api.github.com/users/MichaelChirico/orgs","repos_url":"https://api.github.com/users/MichaelChirico/repos","events_url":"https://api.github.com/users/MichaelChirico/events{/privacy}","received_events_url":"https://api.github.com/users/MichaelChirico/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MichaelChirico/data.table","description":"R's data.table package extends data.frame. More info: ","fork":true,"url":"https://api.github.com/repos/MichaelChirico/data.table","forks_url":"https://api.github.com/repos/MichaelChirico/data.table/forks","keys_url":"https://api.github.com/repos/MichaelChirico/data.table/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MichaelChirico/data.table/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MichaelChirico/data.table/teams","hooks_url":"https://api.github.com/repos/MichaelChirico/data.table/hooks","issue_events_url":"https://api.github.com/repos/MichaelChirico/data.table/issues/events{/number}","events_url":"https://api.github.com/repos/MichaelChirico/data.table/events","assignees_url":"https://api.github.com/repos/MichaelChirico/data.table/assignees{/user}","branches_url":"https://api.github.com/repos/MichaelChirico/data.table/branches{/branch}","tags_url":"https://api.github.com/repos/MichaelChirico/data.table/tags","blobs_url":"https://api.github.com/repos/MichaelChirico/data.table/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MichaelChirico/data.table/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MichaelChirico/data.table/git/refs{/sha}","trees_url":"https://api.github.com/repos/MichaelChirico/data.table/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MichaelChirico/data.table/statuses/{sha}","languages_url":"https://api.github.com/repos/MichaelChirico/data.table/languages","stargazers_url":"https://api.github.com/repos/MichaelChirico/data.table/stargazers","contributors_url":"https://api.github.com/repos/MichaelChirico/data.table/contributors","subscribers_url":"https://api.github.com/repos/MichaelChirico/data.table/subscribers","subscription_url":"https://api.github.com/repos/MichaelChirico/data.table/subscription","commits_url":"https://api.github.com/repos/MichaelChirico/data.table/commits{/sha}","git_commits_url":"https://api.github.com/repos/MichaelChirico/data.table/git/commits{/sha}","comments_url":"https://api.github.com/repos/MichaelChirico/data.table/comments{/number}","issue_comment_url":"https://api.github.com/repos/MichaelChirico/data.table/issues/comments{/number}","contents_url":"https://api.github.com/repos/MichaelChirico/data.table/contents/{+path}","compare_url":"https://api.github.com/repos/MichaelChirico/data.table/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MichaelChirico/data.table/merges","archive_url":"https://api.github.com/repos/MichaelChirico/data.table/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MichaelChirico/data.table/downloads","issues_url":"https://api.github.com/repos/MichaelChirico/data.table/issues{/number}","pulls_url":"https://api.github.com/repos/MichaelChirico/data.table/pulls{/number}","milestones_url":"https://api.github.com/repos/MichaelChirico/data.table/milestones{/number}","notifications_url":"https://api.github.com/repos/MichaelChirico/data.table/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MichaelChirico/data.table/labels{/name}","releases_url":"https://api.github.com/repos/MichaelChirico/data.table/releases{/id}","deployments_url":"https://api.github.com/repos/MichaelChirico/data.table/deployments","created_at":"2015-09-10T23:57:41Z","updated_at":"2016-04-21T14:21:20Z","pushed_at":"2016-09-04T02:54:37Z","git_url":"git://github.com/MichaelChirico/data.table.git","ssh_url":"git@github.com:MichaelChirico/data.table.git","clone_url":"https://github.com/MichaelChirico/data.table.git","svn_url":"https://github.com/MichaelChirico/data.table","homepage":"https://github.com/Rdatatable/data.table/wiki","size":15770,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Rdatatable:master","ref":"master","sha":"81ddf8185d0bc1353e4b5ba5967301971f1515cb","user":{"login":"Rdatatable","id":7824179,"avatar_url":"https://avatars.githubusercontent.com/u/7824179?v=3","gravatar_id":"","url":"https://api.github.com/users/Rdatatable","html_url":"https://github.com/Rdatatable","followers_url":"https://api.github.com/users/Rdatatable/followers","following_url":"https://api.github.com/users/Rdatatable/following{/other_user}","gists_url":"https://api.github.com/users/Rdatatable/gists{/gist_id}","starred_url":"https://api.github.com/users/Rdatatable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rdatatable/subscriptions","organizations_url":"https://api.github.com/users/Rdatatable/orgs","repos_url":"https://api.github.com/users/Rdatatable/repos","events_url":"https://api.github.com/users/Rdatatable/events{/privacy}","received_events_url":"https://api.github.com/users/Rdatatable/received_events","type":"Organization","site_admin":false},"repo":{"id":20597509,"name":"data.table","full_name":"Rdatatable/data.table","owner":{"login":"Rdatatable","id":7824179,"avatar_url":"https://avatars.githubusercontent.com/u/7824179?v=3","gravatar_id":"","url":"https://api.github.com/users/Rdatatable","html_url":"https://github.com/Rdatatable","followers_url":"https://api.github.com/users/Rdatatable/followers","following_url":"https://api.github.com/users/Rdatatable/following{/other_user}","gists_url":"https://api.github.com/users/Rdatatable/gists{/gist_id}","starred_url":"https://api.github.com/users/Rdatatable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rdatatable/subscriptions","organizations_url":"https://api.github.com/users/Rdatatable/orgs","repos_url":"https://api.github.com/users/Rdatatable/repos","events_url":"https://api.github.com/users/Rdatatable/events{/privacy}","received_events_url":"https://api.github.com/users/Rdatatable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Rdatatable/data.table","description":"R's data.table package extends data.frame. HOMEPAGE: ","fork":false,"url":"https://api.github.com/repos/Rdatatable/data.table","forks_url":"https://api.github.com/repos/Rdatatable/data.table/forks","keys_url":"https://api.github.com/repos/Rdatatable/data.table/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Rdatatable/data.table/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Rdatatable/data.table/teams","hooks_url":"https://api.github.com/repos/Rdatatable/data.table/hooks","issue_events_url":"https://api.github.com/repos/Rdatatable/data.table/issues/events{/number}","events_url":"https://api.github.com/repos/Rdatatable/data.table/events","assignees_url":"https://api.github.com/repos/Rdatatable/data.table/assignees{/user}","branches_url":"https://api.github.com/repos/Rdatatable/data.table/branches{/branch}","tags_url":"https://api.github.com/repos/Rdatatable/data.table/tags","blobs_url":"https://api.github.com/repos/Rdatatable/data.table/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Rdatatable/data.table/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Rdatatable/data.table/git/refs{/sha}","trees_url":"https://api.github.com/repos/Rdatatable/data.table/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Rdatatable/data.table/statuses/{sha}","languages_url":"https://api.github.com/repos/Rdatatable/data.table/languages","stargazers_url":"https://api.github.com/repos/Rdatatable/data.table/stargazers","contributors_url":"https://api.github.com/repos/Rdatatable/data.table/contributors","subscribers_url":"https://api.github.com/repos/Rdatatable/data.table/subscribers","subscription_url":"https://api.github.com/repos/Rdatatable/data.table/subscription","commits_url":"https://api.github.com/repos/Rdatatable/data.table/commits{/sha}","git_commits_url":"https://api.github.com/repos/Rdatatable/data.table/git/commits{/sha}","comments_url":"https://api.github.com/repos/Rdatatable/data.table/comments{/number}","issue_comment_url":"https://api.github.com/repos/Rdatatable/data.table/issues/comments{/number}","contents_url":"https://api.github.com/repos/Rdatatable/data.table/contents/{+path}","compare_url":"https://api.github.com/repos/Rdatatable/data.table/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Rdatatable/data.table/merges","archive_url":"https://api.github.com/repos/Rdatatable/data.table/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Rdatatable/data.table/downloads","issues_url":"https://api.github.com/repos/Rdatatable/data.table/issues{/number}","pulls_url":"https://api.github.com/repos/Rdatatable/data.table/pulls{/number}","milestones_url":"https://api.github.com/repos/Rdatatable/data.table/milestones{/number}","notifications_url":"https://api.github.com/repos/Rdatatable/data.table/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Rdatatable/data.table/labels{/name}","releases_url":"https://api.github.com/repos/Rdatatable/data.table/releases{/id}","deployments_url":"https://api.github.com/repos/Rdatatable/data.table/deployments","created_at":"2014-06-07T16:38:05Z","updated_at":"2016-09-03T15:16:44Z","pushed_at":"2016-09-04T03:07:11Z","git_url":"git://github.com/Rdatatable/data.table.git","ssh_url":"git@github.com:Rdatatable/data.table.git","clone_url":"https://github.com/Rdatatable/data.table.git","svn_url":"https://github.com/Rdatatable/data.table","homepage":"https://github.com/Rdatatable/data.table/wiki","size":19363,"stargazers_count":800,"watchers_count":800,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":535,"mirror_url":null,"open_issues_count":426,"forks":535,"open_issues":426,"watchers":800,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Rdatatable/data.table/pulls/1839"},"html":{"href":"https://github.com/Rdatatable/data.table/pull/1839"},"issue":{"href":"https://api.github.com/repos/Rdatatable/data.table/issues/1839"},"comments":{"href":"https://api.github.com/repos/Rdatatable/data.table/issues/1839/comments"},"review_comments":{"href":"https://api.github.com/repos/Rdatatable/data.table/pulls/1839/comments"},"review_comment":{"href":"https://api.github.com/repos/Rdatatable/data.table/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Rdatatable/data.table/pulls/1839/commits"},"statuses":{"href":"https://api.github.com/repos/Rdatatable/data.table/statuses/bbaf7c600bdfbe612b0d0e3c44019ed6cce140cd"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":25,"deletions":3,"changed_files":4}}
{"actor":{"display_login":"MichaelChirico"}}