### Name: read.ftable ### Title: Manipulate Flat Contingency Tables ### Aliases: read.ftable write.ftable format.ftable ### Keywords: category ### ** Examples ## Agresti (1990), page 157, Table 5.8. ## Not in ftable standard format, but o.k. file <- tempfile() cat(" Intercourse\n", "Race Gender Yes No\n", "White Male 43 134\n", " Female 26 149\n", "Black Male 29 23\n", " Female 22 36\n", file = file) file.show(file) ft <- read.ftable(file) ft unlink(file) ## Agresti (1990), page 297, Table 8.16. ## Almost o.k., but misses the name of the row variable. file <- tempfile() cat(" \"Tonsil Size\"\n", " \"Not Enl.\" \"Enl.\" \"Greatly Enl.\"\n", "Noncarriers 497 560 269\n", "Carriers 19 29 24\n", file = file) file.show(file) ft <- read.ftable(file, skip = 2, row.var.names = "Status", col.vars = list("Tonsil Size" = c("Not Enl.", "Enl.", "Greatly Enl."))) ft unlink(file) ft22 <- ftable(Titanic, row.vars = 2:1, col.vars = 4:3) write.ftable(ft22, quote = FALSE) ## Don't show: stopifnot(dim(format(ft)) == 4:5, dim(format(ftable(UCBAdmissions))) == c(6,9), dim(format(ft22)) == c(11,7)) ## End Don't show