{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/dplyr/issues/1335","labels_url":"https://api.github.com/repos/hadley/dplyr/issues/1335/labels{/name}","comments_url":"https://api.github.com/repos/hadley/dplyr/issues/1335/comments","events_url":"https://api.github.com/repos/hadley/dplyr/issues/1335/events","html_url":"https://github.com/hadley/dplyr/issues/1335","id":102646704,"number":1335,"title":"Interleave multiple function summarise_each() output [Feature Request]","user":{"login":"bhive01","id":394973,"avatar_url":"https://avatars.githubusercontent.com/u/394973?v=3","gravatar_id":"","url":"https://api.github.com/users/bhive01","html_url":"https://github.com/bhive01","followers_url":"https://api.github.com/users/bhive01/followers","following_url":"https://api.github.com/users/bhive01/following{/other_user}","gists_url":"https://api.github.com/users/bhive01/gists{/gist_id}","starred_url":"https://api.github.com/users/bhive01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhive01/subscriptions","organizations_url":"https://api.github.com/users/bhive01/orgs","repos_url":"https://api.github.com/users/bhive01/repos","events_url":"https://api.github.com/users/bhive01/events{/privacy}","received_events_url":"https://api.github.com/users/bhive01/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-23T18:52:10Z","updated_at":"2015-08-24T21:49:32Z","closed_at":null,"body":"Currently if you have multiple functions in a summarise_each() call, you get the following:\r\n(funs(mean, sd))\r\nGroup_by Column, Mean1, Mean2, SD1, SD2\r\n\r\nAn example:\r\n```R\r\nlibrary(dplyr)\r\n\r\ndf <- data.frame(name=rep(LETTERS[1:3], each=20), weight=runif(60,60, 100), height=runif(60, 100, 150))\r\n\r\ndf %>%\r\ngroup_by(name) %>%\r\nsummarise_each(., funs(mean(., na.rm=TRUE), sd(., na.rm=TRUE)))\r\n```\r\nIn many cases these tables are the final product for showing to others and/or a springboard for further exploratory analysis, but I usually find myself wanting to reorder the columns like so: \r\n\r\nGroup_by Column, Mean1, SD1, Mean2, SD2\r\n\r\nDennis had a solution of the following and I believe it could be made more general, but I'm unsure of the best approach: \r\n\r\n```R\r\ndf %>%\r\ngroup_by(name) %>%\r\nsummarise_each(., funs(mean(., na.rm=TRUE), sd(., na.rm=TRUE))) %>%\r\n`[`(., c(1, 2, 4, 3, 5))\r\n```\r\n\r\nSeems like you could isolate the grouped by columns subtract them from ncol(), divide by the number of functions, and interleave based upon that. Doesn't seem that simple, but someone must have already figured this out. Dennis said that plyr::colwise() did this, but it's been ages since I've used plyr.\r\n"},"comment":{"url":"https://api.github.com/repos/hadley/dplyr/issues/comments/134390497","html_url":"https://github.com/hadley/dplyr/issues/1335#issuecomment-134390497","issue_url":"https://api.github.com/repos/hadley/dplyr/issues/1335","id":134390497,"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-24T21:49:32Z","updated_at":"2015-08-24T21:49:32Z","body":"Related to #154 "}}