inst/examples/ex-with_margins.R

library(dplyr)
x <- c( 'a', 'b', 'c')
y <- c( 'd', 'e', 'f')
data <- group_by(mutate(expand.grid( x = x, y = y, .rep = 1:10),  v = rnorm(90)), x, y)
with_margins(summarise)(data, N=n(), sum=sum(v))

Try the tidymargins package in your browser

Any scripts or data that you put into this service are public.

tidymargins documentation built on July 23, 2019, 5:04 p.m.