The R Project SVN R

Rev

Rev 61411 | Rev 64745 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61411 Rev 62158
Line 85... Line 85...
85
\examples{
85
\examples{
86
## Start with a contingency table.
86
## Start with a contingency table.
87
ftable(Titanic, row.vars = 1:3)
87
ftable(Titanic, row.vars = 1:3)
88
ftable(Titanic, row.vars = 1:2, col.vars = "Survived")
88
ftable(Titanic, row.vars = 1:2, col.vars = "Survived")
89
ftable(Titanic, row.vars = 2:1, col.vars = "Survived")
89
ftable(Titanic, row.vars = 2:1, col.vars = "Survived")
-
 
90
\dontshow{%% must work
-
 
91
. <- integer()
-
 
92
(f04 <- ftable(Titanic, col.vars= .))
-
 
93
(f10 <- ftable(Titanic, col.vars= 1, row.vars= .))
-
 
94
(f01 <- ftable(Titanic, col.vars= ., row.vars= 1))
-
 
95
(f00 <- ftable(Titanic, col.vars= ., row.vars= .))
-
 
96
stopifnot(
-
 
97
  dim(f04) == c(32,1),
-
 
98
  dim(f10) == c(1,4),
-
 
99
  dim(f01) == c(4,1),
-
 
100
  dim(f00) == c(1,1))
90
 
101
}
91
## Start with a data frame.
102
## Start with a data frame.
92
x <- ftable(mtcars[c("cyl", "vs", "am", "gear")])
103
x <- ftable(mtcars[c("cyl", "vs", "am", "gear")])
93
x
104
x
94
ftable(x, row.vars = c(2, 4))
105
ftable(x, row.vars = c(2, 4))
95
 
106