I am wondering if there is a way to use functions with summarise
(dplyr 0.1.2
) that return multiple values (for instance the describe
function from psych
package).
If not, is it just because it hasn't been implemented yet, or is there a reason that it wouldn't be a good idea?
Example:
require(psych)
require(ggplot2)
require(dplyr)
dgrp <- group_by(diamonds, cut)
describe(dgrp$price)
summarise(dgrp, describe(price))
produces: Error: expecting a single value
With
dplyr
>= 0.2 we can usedo
function for this:Solution based on the
purrr
package:But it so simply with
data.table
:We can write own summary function which returns a list: