{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/lowliner/issues/30","labels_url":"https://api.github.com/repos/hadley/lowliner/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/hadley/lowliner/issues/30/comments","events_url":"https://api.github.com/repos/hadley/lowliner/issues/30/events","html_url":"https://github.com/hadley/lowliner/pull/30","id":53797652,"number":30,"title":"Let splat() specify default arguments for .f","user":{"login":"lionelgit","id":4465050,"avatar_url":"https://avatars.githubusercontent.com/u/4465050?v=3","gravatar_id":"","url":"https://api.github.com/users/lionelgit","html_url":"https://github.com/lionelgit","followers_url":"https://api.github.com/users/lionelgit/followers","following_url":"https://api.github.com/users/lionelgit/following{/other_user}","gists_url":"https://api.github.com/users/lionelgit/gists{/gist_id}","starred_url":"https://api.github.com/users/lionelgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lionelgit/subscriptions","organizations_url":"https://api.github.com/users/lionelgit/orgs","repos_url":"https://api.github.com/users/lionelgit/repos","events_url":"https://api.github.com/users/lionelgit/events{/privacy}","received_events_url":"https://api.github.com/users/lionelgit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-08T20:34:56Z","updated_at":"2015-01-11T16:49:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hadley/lowliner/pulls/30","html_url":"https://github.com/hadley/lowliner/pull/30","diff_url":"https://github.com/hadley/lowliner/pull/30.diff","patch_url":"https://github.com/hadley/lowliner/pull/30.patch"},"body":"This lets `splat()` accept additional arguments that are fed to `.f` as defaults.\r\n\r\nWhen we pipe a list into a splatted function, it is often necessary to take care of additional arguments. That typically means adjusting the main list with additional arguments by using a temporary variable or `append()`ing  them in the middle of the pipe chain. Being able to specify these arguments directly in `splat()` hopefully leads to clearer code because the main arguments and the side arguments are specified separately (the former in the pipe chain and the latter in `splat()`)."},"comment":{"url":"https://api.github.com/repos/hadley/lowliner/issues/comments/69500980","html_url":"https://github.com/hadley/lowliner/pull/30#issuecomment-69500980","issue_url":"https://api.github.com/repos/hadley/lowliner/issues/30","id":69500980,"user":{"login":"lionelgit","id":4465050,"avatar_url":"https://avatars.githubusercontent.com/u/4465050?v=3","gravatar_id":"","url":"https://api.github.com/users/lionelgit","html_url":"https://github.com/lionelgit","followers_url":"https://api.github.com/users/lionelgit/followers","following_url":"https://api.github.com/users/lionelgit/following{/other_user}","gists_url":"https://api.github.com/users/lionelgit/gists{/gist_id}","starred_url":"https://api.github.com/users/lionelgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lionelgit/subscriptions","organizations_url":"https://api.github.com/users/lionelgit/orgs","repos_url":"https://api.github.com/users/lionelgit/repos","events_url":"https://api.github.com/users/lionelgit/events{/privacy}","received_events_url":"https://api.github.com/users/lionelgit/received_events","type":"User","site_admin":false},"created_at":"2015-01-11T16:49:01Z","updated_at":"2015-01-11T16:49:01Z","body":"In #33 I mentioned the idea of having\r\n> differing function signatures as a function of the type of the first argument\r\n\r\nAlong these lines, it could also make sense to have a dual behavior for `splat()` such it would behave as a functional or as a factory function depending on the type of the first argument.\r\n```{r}\r\nsplat(fun)(x) # factory function\r\nsplat(x, fun) # functional (equivalent to do.call with x as first arg)\r\n```\r\n\r\nI don't like factory functions so much in pipes because the parentheses are syntax heavy. With the dual behavior we could write\r\n```{r}\r\nx %>%\r\n  map(fun1) %>%\r\n  splat(fun2)\r\n```\r\ninstead of\r\n```{r}\r\nx %>%\r\n  map(fun1) %>%\r\n  splat(fun2)()\r\n```"}}