{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/dplyr/issues/1176","labels_url":"https://api.github.com/repos/hadley/dplyr/issues/1176/labels{/name}","comments_url":"https://api.github.com/repos/hadley/dplyr/issues/1176/comments","events_url":"https://api.github.com/repos/hadley/dplyr/issues/1176/events","html_url":"https://github.com/hadley/dplyr/issues/1176","id":81765809,"number":1176,"title":"in dplyr select with a drop does not work, when no matches","user":{"login":"gunapemmaraju","id":8115700,"avatar_url":"https://avatars.githubusercontent.com/u/8115700?v=3","gravatar_id":"","url":"https://api.github.com/users/gunapemmaraju","html_url":"https://github.com/gunapemmaraju","followers_url":"https://api.github.com/users/gunapemmaraju/followers","following_url":"https://api.github.com/users/gunapemmaraju/following{/other_user}","gists_url":"https://api.github.com/users/gunapemmaraju/gists{/gist_id}","starred_url":"https://api.github.com/users/gunapemmaraju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gunapemmaraju/subscriptions","organizations_url":"https://api.github.com/users/gunapemmaraju/orgs","repos_url":"https://api.github.com/users/gunapemmaraju/repos","events_url":"https://api.github.com/users/gunapemmaraju/events{/privacy}","received_events_url":"https://api.github.com/users/gunapemmaraju/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-28T05:20:32Z","updated_at":"2015-06-17T15:59:26Z","closed_at":null,"body":"In dplyr, I want to exclude columns which contain the word \"junk\" but, there may not be any column that contain the word \"junk\". In that case, dplyr should return all columns. But it returns none. See unit test case below.\r\n\r\ndf<-data.frame(name=paste(\"name\",1:5), age=1:5)\r\nstr(df)\r\n 'data.frame': 5 obs. of  2 variables:\r\n $ name: Factor w/ 5 levels \"name 1\",\"name 2\",..: 1 2 3 4 5\r\n $ age : int  1 2 3 4 5\r\ndf1<-df%>%select(-contains(\"junk\"))\r\nstr(df1)\r\n 'data.frame': 5 obs. of  0 variables\r\n\r\nMore at\r\n\r\nhttp://stackoverflow.com/questions/30496930/in-dplyr-select-with-a-drop-does-not-work\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/hadley/dplyr/issues/comments/112860110","html_url":"https://github.com/hadley/dplyr/issues/1176#issuecomment-112860110","issue_url":"https://api.github.com/repos/hadley/dplyr/issues/1176","id":112860110,"user":{"login":"drewgendreau","id":5003237,"avatar_url":"https://avatars.githubusercontent.com/u/5003237?v=3","gravatar_id":"","url":"https://api.github.com/users/drewgendreau","html_url":"https://github.com/drewgendreau","followers_url":"https://api.github.com/users/drewgendreau/followers","following_url":"https://api.github.com/users/drewgendreau/following{/other_user}","gists_url":"https://api.github.com/users/drewgendreau/gists{/gist_id}","starred_url":"https://api.github.com/users/drewgendreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewgendreau/subscriptions","organizations_url":"https://api.github.com/users/drewgendreau/orgs","repos_url":"https://api.github.com/users/drewgendreau/repos","events_url":"https://api.github.com/users/drewgendreau/events{/privacy}","received_events_url":"https://api.github.com/users/drewgendreau/received_events","type":"User","site_admin":false},"created_at":"2015-06-17T15:59:26Z","updated_at":"2015-06-17T15:59:26Z","body":"Just wanted to add that I tried doing this earlier today and was surprised to find that \r\n\r\ndf %>% select(-contains(\"this_string_is_definitely_not_in_any_of_the_column_names\") )\r\n\r\nreturns an empty data.frame.  The use case is that I'm running a program where I don't know all the column names ahead of time, but if there is one with a particular string I'd like to drop it."}}