n <- c(53, 11, 0, 4, 414, 37, 16, 139) dp <- data.frame(P=c(rep("Y",4),rep("N",4)),n) dp <- cbind(D=rep(c("W","B"),4),dp) dp <- cbind(V=rep(c(rep("W",2),rep("B",2)),2),dp) # can recover original table with ftable(xtabs(n ~ V + D + P ,data=dp)) # [but not reversal of order of W and B...]