Getting totals in R for a 2x2x2 contingency table -


i have data 3 binary variables of following form:

      b  c      1  1  1      1  0  0      0  1  0      .  .  .      .  .  . 

suppose factor controlling.how frequencies of 2x2 tables created b , c each level of a?

try:

df <- expand.grid(a = c(1,1,0), b = sample(0:1, 100, t), c = sample(0:1, 100, t))  library(dplyr) df %>% group_by(a) %>% summarise_each(funs(sum)) 

this keep data in data frame (instead of list using table())

#source: local data frame [2 x 3] # #     b     c #1 0 4700  5400 #2 1 9400 10800 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -