read.ftable(stats)
read.ftable()所属R语言包:stats
Manipulate Flat Contingency Tables
操纵平面应变表
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Read, write and coerce "flat" contingency tables.
读,写和要挟“平面”联表。
用法----------Usage----------
read.ftable(file, sep = "", quote = "\"",
row.var.names, col.vars, skip = 0)
write.ftable(x, file = "", quote = TRUE, append = FALSE,
digits = getOption("digits"))
## S3 method for class 'ftable'
format(x, quote = TRUE, digits = getOption("digits"), ...)
参数----------Arguments----------
参数:file
either a character string naming a file or a connection which the data are to be read from or written to. "" indicates input from the console for reading and output to the console for writing.
无论是一个字符串,命名一个文件或一个连接要读取或写入数据。 ""表示从阅读和写作的控制台输出的控制台输入。
参数:sep
the field separator string. Values on each line of the file are separated by this string.
字段分隔符字符串。这个字符串分隔文件的每一行的值。
参数:quote
a character string giving the set of quoting characters for read.ftable; to disable quoting altogether, use quote="". For write.table, a logical indicating whether strings in the data will be surrounded by double quotes.
一个字符串引用字符read.ftable一套完全禁用引用,使用quote=""。 write.table,逻辑指示是否将由双引号包围的字符串数据。
参数:row.var.names
a character vector with the names of the row variables, in case these cannot be determined automatically.
特征向量与行的变量的名称,这些情况不能被自动确定。
参数:col.vars
a list giving the names and levels of the column variables, in case these cannot be determined automatically.
列表,列变量的名称和水平,这些情况不能被自动确定。
参数:skip
the number of lines of the data file to skip before beginning to read data.
行的数据文件数量开始读取数据前跳过。
参数:x
an object of class "ftable".
对象类"ftable"。
参数:append
logical. If TRUE and file is the name of a file (and not a connection or "|cmd"), the output from write.ftable is appended to the file. If FALSE, the contents of file will be overwritten.
逻辑。如果TRUE和file是一个文件(而不是一个连接或"|cmd"),从write.ftable输出的被追加到文件的名称。如果FALSE,file的内容将被覆盖。
参数:digits
an integer giving the number of significant digits to use for (the cell entries of) x.
一个整数,有效位数的号码使用(单元条目)x。
参数:...
further arguments to be passed to or from methods.
进一步的参数被传递到或从方法。
Details
详情----------Details----------
read.ftable reads in a flat-like contingency table from a file. If the file contains the written representation of a flat table (more precisely, a header with all information on names and levels of column variables, followed by a line with the names of the row variables), no further arguments are needed. Similarly, flat tables with only one column variable the name of which is the only entry in the first line are handled automatically. Other variants can be dealt with by skipping all header information using skip, and providing the names of the row variables and the names and levels of the column variable using row.var.names and col.vars, respectively. See the examples below.
read.ftable扁平状的应变表从一个文件中读取。如果该文件包含一个平面表(更确切地说,与列变量的名称和水平上的所有信息的标题,一行行变量的名称)的书面陈述,没有进一步的论据是必要的。同样,只有一列变量的名字,这是在第一线的唯一条目的平面表自动处理。其他变种可以跳过所有的头信息使用skip,并提供行变量和列变量的名称和水平的名称,使用row.var.names和col.vars,分别处理。见下面的例子。
Note that flat tables are characterized by their "ragged" display of row (and maybe also column) labels. If the full grid of levels of the row variables is given, one should instead use read.table to read in the data, and create the contingency table from this using xtabs.
需要注意的是平面表的特点是他们的“破烂”显示行(也许还列)标签。如果是满格的行变量的水平,应该改用read.table读取数据,并建立应急使用xtabs表。
write.ftable writes a flat table to a file, which is useful for generating "pretty" ASCII representations of contingency tables.
write.ftable一个平面表写入到一个文件,产生应急表漂亮的ASCII表示,这是有用的。
参考文献----------References----------
Categorical data analysis. New York: Wiley.
参见----------See Also----------
ftable for more information on flat contingency tables.
ftable平面应变表的更多信息。
举例----------Examples----------
## Agresti (1990), page 157, Table 5.8.[#Agresti(1990),第157页,表5.8。]
## Not in ftable standard format, but o.k.[#不标准格式ftable,但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.[#Agresti(1990),第297页,表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)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|