Skip to content

Instantly share code, notes, and snippets.

@kosugitti
Last active February 7, 2019 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosugitti/a732f7d07957517af7259af62c0211c8 to your computer and use it in GitHub Desktop.
Save kosugitti/a732f7d07957517af7259af62c0211c8 to your computer and use it in GitHub Desktop.
群ごとの平均
A <- factor(rep(1:2,each=8),labels=LETTERS[1:2])
B <- factor(rep(rep(1:4,each=2),2),labels=letters[1:4])
C <- factor(rep(1:2,8),labels=c("あ","い"))
dat <- data.frame(A,B,C)
dat$val <- rnorm(16,0,1)
library(tidyverse)
dat %>% group_by(A,B) %>% summarise(means=mean(val))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment