How do I merge (add) contingency tables:
> (t1 <- table(c("a","b","b","c")))
a b c
1 2 1
> (t2 <- table(c("c","d","d","a")))
a c d
1 1 2
I want this:
a b c d
2 2 2 2
How do I merge (add) contingency tables:
> (t1 <- table(c("a","b","b","c")))
a b c
1 2 1
> (t2 <- table(c("c","d","d","a")))
a c d
1 1 2
I want this:
a b c d
2 2 2 2
You can do it using
split
andsapply
Or directly using
tapply
as pointed out by @ArunHere is what I was able to come up with:
I think there must be a better way...
This works: