{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/lineprof/issues/28","labels_url":"https://api.github.com/repos/hadley/lineprof/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/hadley/lineprof/issues/28/comments","events_url":"https://api.github.com/repos/hadley/lineprof/issues/28/events","html_url":"https://github.com/hadley/lineprof/pull/28","id":52051873,"number":28,"title":"Fix a bug in contains","user":{"login":"saurfang","id":4317392,"avatar_url":"https://avatars.githubusercontent.com/u/4317392?v=3","gravatar_id":"","url":"https://api.github.com/users/saurfang","html_url":"https://github.com/saurfang","followers_url":"https://api.github.com/users/saurfang/followers","following_url":"https://api.github.com/users/saurfang/following{/other_user}","gists_url":"https://api.github.com/users/saurfang/gists{/gist_id}","starred_url":"https://api.github.com/users/saurfang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saurfang/subscriptions","organizations_url":"https://api.github.com/users/saurfang/orgs","repos_url":"https://api.github.com/users/saurfang/repos","events_url":"https://api.github.com/users/saurfang/events{/privacy}","received_events_url":"https://api.github.com/users/saurfang/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-12-15T23:07:40Z","updated_at":"2015-01-08T13:10:41Z","closed_at":"2015-01-08T12:45:12Z","pull_request":{"url":"https://api.github.com/repos/hadley/lineprof/pulls/28","html_url":"https://github.com/hadley/lineprof/pull/28","diff_url":"https://github.com/hadley/lineprof/pull/28.diff","patch_url":"https://github.com/hadley/lineprof/pull/28.patch"},"body":"There is a bug in `contains` when the `haystack` contains duplicates that is part of `needle`.\r\n\r\nFor example\r\n```r\r\nlineprof:::contains(c(\"a\",\"a\",\"b\"), c(\"a\",\"b\"))\r\n```\r\nreturns 0 where it should return 2\r\n\r\nThis seems to cause #16. I also encountered similar issues when profiling codes that use  `dplyr` where consecutive nested `eval` is quite common with `magrittr`.\r\n\r\nI have tested with the following\r\n```r\r\nlineprof:::contains(c(\"a\",\"a\",\"b\"), c(\"a\"))\r\n# 1\r\nlineprof:::contains(c(\"a\",\"a\",\"b\"), c(\"a\", \"b\"))\r\n# 2\r\nlineprof:::contains(c(\"a\",\"a\",\"b\"), c(\"a\", \"c\"))\r\n# 0\r\nlineprof:::contains(c(\"a\",\"a\",\"b\"), c(\"c\"))\r\n# 0\r\nlineprof:::contains(c(\"a\",\"a\",\"b\"), character())\r\n# 1\r\n```\r\n\r\nLet me know if there is any concerns/suggestions on the implementation logic or code style."},"comment":{"url":"https://api.github.com/repos/hadley/lineprof/issues/comments/69176893","html_url":"https://github.com/hadley/lineprof/pull/28#issuecomment-69176893","issue_url":"https://api.github.com/repos/hadley/lineprof/issues/28","id":69176893,"user":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"created_at":"2015-01-08T13:10:41Z","updated_at":"2015-01-08T13:10:41Z","body":"I couldn't figure it out, so I just disabled the profiling for now. I'm guessing R CMD check sets something that prevents Rprof from working"}}