The documentation for ftable
tells us that "ftable
creates ‘flat’ contingency tables". However, the meaning of this isn't getting through to me. I've placed two examples below, but they look so similar that I feel like I'm completely missing the distinction between table
and ftable
. Am I ignorant of some critical programming or statistical idea?
> ftable(mtcars[c("cyl", "vs", "am", "gear")])
gear 3 4 5
cyl vs am
4 0 0 0 0 0
1 0 0 1
1 0 1 2 0
1 0 6 1
6 0 0 0 0 0
1 0 2 1
1 0 2 2 0
1 0 0 0
8 0 0 12 0 0
1 0 0 2
1 0 0 0 0
1 0 0 0
> table(mtcars[c("cyl", "vs", "am", "gear")])
, , am = 0, gear = 3
vs
cyl 0 1
4 0 1
6 0 2
8 12 0
, , am = 1, gear = 3
vs
cyl 0 1
4 0 0
6 0 0
8 0 0
, , am = 0, gear = 4
vs
cyl 0 1
4 0 2
6 0 2
8 0 0
, , am = 1, gear = 4
vs
cyl 0 1
4 0 6
6 2 0
8 0 0
, , am = 0, gear = 5
vs
cyl 0 1
4 0 0
6 0 0
8 0 0
, , am = 1, gear = 5
vs
cyl 0 1
4 1 1
6 1 0
8 2 0
My suspicion is that it means "flat" as in "flattern a nested list", but if that was the case, then I'm not sure why I cannot feed exactly the same arguments to ftable
as I can table
. For example, ftable(Titanic, row.vars = 1:3)
is valid, but table(Titanic, row.vars = 1:3)
throws an error about the arguments having non-equal lengths.