{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/dplyr/issues/1205","labels_url":"https://api.github.com/repos/hadley/dplyr/issues/1205/labels{/name}","comments_url":"https://api.github.com/repos/hadley/dplyr/issues/1205/comments","events_url":"https://api.github.com/repos/hadley/dplyr/issues/1205/events","html_url":"https://github.com/hadley/dplyr/issues/1205","id":86225443,"number":1205,"title":"setNames in NSE ","user":{"login":"matthieugomez","id":6223837,"avatar_url":"https://avatars.githubusercontent.com/u/6223837?v=3","gravatar_id":"","url":"https://api.github.com/users/matthieugomez","html_url":"https://github.com/matthieugomez","followers_url":"https://api.github.com/users/matthieugomez/followers","following_url":"https://api.github.com/users/matthieugomez/following{/other_user}","gists_url":"https://api.github.com/users/matthieugomez/gists{/gist_id}","starred_url":"https://api.github.com/users/matthieugomez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthieugomez/subscriptions","organizations_url":"https://api.github.com/users/matthieugomez/orgs","repos_url":"https://api.github.com/users/matthieugomez/repos","events_url":"https://api.github.com/users/matthieugomez/events{/privacy}","received_events_url":"https://api.github.com/users/matthieugomez/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-08T15:34:39Z","updated_at":"2015-07-02T19:52:29Z","closed_at":"2015-06-18T11:18:14Z","body":"When setting the names of new variable using the NSE functions, one needs to use setNames, which can make code hard to read.\r\n\r\nWould it be possible to allow left hand side in formulas?\r\n\r\nThis would allow to write\r\n\r\n```R\r\nsummarise_(mtcars,  mean ~ mean(mpg))\r\n```\r\n\r\ninstead of \r\n\r\n```R\r\nsummarise_(mtcars, .dots = setNames(list(~mean(mpg)), \"mean\"))\r\n```"},"comment":{"url":"https://api.github.com/repos/hadley/dplyr/issues/comments/118146911","html_url":"https://github.com/hadley/dplyr/issues/1205#issuecomment-118146911","issue_url":"https://api.github.com/repos/hadley/dplyr/issues/1205","id":118146911,"user":{"login":"matthieugomez","id":6223837,"avatar_url":"https://avatars.githubusercontent.com/u/6223837?v=3","gravatar_id":"","url":"https://api.github.com/users/matthieugomez","html_url":"https://github.com/matthieugomez","followers_url":"https://api.github.com/users/matthieugomez/followers","following_url":"https://api.github.com/users/matthieugomez/following{/other_user}","gists_url":"https://api.github.com/users/matthieugomez/gists{/gist_id}","starred_url":"https://api.github.com/users/matthieugomez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthieugomez/subscriptions","organizations_url":"https://api.github.com/users/matthieugomez/orgs","repos_url":"https://api.github.com/users/matthieugomez/repos","events_url":"https://api.github.com/users/matthieugomez/events{/privacy}","received_events_url":"https://api.github.com/users/matthieugomez/received_events","type":"User","site_admin":false},"created_at":"2015-07-02T19:52:29Z","updated_at":"2015-07-02T19:52:29Z","body":"My point was really about using `mutate_` or `summarise_` inside a program, where you don't know the variable names\r\n\r\nFor instance, to write a function that demean a variable given as an argument\r\n```r\r\nlibrary(lazyeval)\r\nf <- function(df, oldvar)\r\nnewvar = paste0(oldvar, \"new\")\r\naction = interp(~mean(x), x = oldvar)\r\nsummarise(df, .dots = setNames(list(action, newvar)))\r\n```\r\n\r\nBut it would look cleaner to write\r\n```r\r\nlibrary(lazyeval)\r\nf <- function(oldvar)\r\nnewvar = paste0(oldvar, \"new\")\r\naction = interp(y~mean(x), x = oldvar, y = newvar)\r\nsummarise(mtcars, .dots = action)\r\n```\r\n\r\n"}}