{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/dplyr/issues/1156","labels_url":"https://api.github.com/repos/hadley/dplyr/issues/1156/labels{/name}","comments_url":"https://api.github.com/repos/hadley/dplyr/issues/1156/comments","events_url":"https://api.github.com/repos/hadley/dplyr/issues/1156/events","html_url":"https://github.com/hadley/dplyr/issues/1156","id":78603152,"number":1156,"title":"Renaming multiple variables prefixes column positions instead of names","user":{"login":"holstius","id":825962,"avatar_url":"https://avatars.githubusercontent.com/u/825962?v=3","gravatar_id":"","url":"https://api.github.com/users/holstius","html_url":"https://github.com/holstius","followers_url":"https://api.github.com/users/holstius/followers","following_url":"https://api.github.com/users/holstius/following{/other_user}","gists_url":"https://api.github.com/users/holstius/gists{/gist_id}","starred_url":"https://api.github.com/users/holstius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holstius/subscriptions","organizations_url":"https://api.github.com/users/holstius/orgs","repos_url":"https://api.github.com/users/holstius/repos","events_url":"https://api.github.com/users/holstius/events{/privacy}","received_events_url":"https://api.github.com/users/holstius/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-20T16:49:22Z","updated_at":"2015-08-24T22:24:37Z","closed_at":"2015-08-24T22:24:37Z","body":"It seems like `select()` has a great intention here. Per `?select`,\r\n\r\n    # Renaming multiple variables uses a prefix:\r\n    select(iris, petal = starts_with(\"Petal\"))\r\n\r\nThis results in names `petal1` and `petal2`. Why not `petalPetal.Length` and `petalPetal.Width`?\r\n\r\nIf `select()` retained the column *names*, instead of column positions, I think it would be much more useful for prefixing prior to joins. For example:\r\n\r\n    stopifnot(require(\"Lahman\"))\r\n    \r\n    batting_df <- tbl_df(Batting)\r\n    person_df <- tbl_df(Master) \r\n    \r\n    # Prefix vars from `batting_df` with \"batting_\"\r\n    batting_df %>% \r\n      select(playerID, batting_ = -matches(\"playerID\")) %>% \r\n      inner_join(person_df, by = \"playerID\")\r\n\r\nThis might help work around the lack of a `suffixes = ` argument in the various `_join` functions. (To preserve uniqueness, just rename the otherwise-duplicated variables in each table before joining.)"},"comment":{"url":"https://api.github.com/repos/hadley/dplyr/issues/comments/134398908","html_url":"https://github.com/hadley/dplyr/issues/1156#issuecomment-134398908","issue_url":"https://api.github.com/repos/hadley/dplyr/issues/1156","id":134398908,"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-08-24T22:24:37Z","updated_at":"2015-08-24T22:24:37Z","body":"I'd rather fix this by controlling the suffixes."}}