找回密码
 注册
查看: 9715|回复: 0

R语言:write.table()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 20:49:58 | 显示全部楼层 |阅读模式
write.table(utils)
write.table()所属R语言包:utils

                                        Data Output
                                         数据输出

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

write.table prints its required argument x (after converting it to a data frame if it is not one nor a matrix) to a file or connection.
write.table打印其所需的x(后,将其转换为一个数据框,如果它不是,也不是一个矩阵)文件或连接参数。


用法----------Usage----------


write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ",
            eol = "\n", na = "NA", dec = ".", row.names = TRUE,
            col.names = TRUE, qmethod = c("escape", "double"),
            fileEncoding = "")

write.csv(...)
write.csv2(...)



参数----------Arguments----------

参数:x
the object to be written, preferably a matrix or data frame. If not, it is attempted to coerce x to a data frame.
要写入的对象,最好是矩阵或数据框。如果不是,它是试图强迫x到一个数据框。


参数:file
either a character string naming a file or a connection open for writing.  "" indicates output to the console.
无论是一个字符串命名文件或写作中打开一个连接。 ""表示输出到控制台。


参数:append
logical. Only relevant if file is a character string.  If TRUE, the output is appended to the file.  If FALSE, any existing file of the name is destroyed.
逻辑。唯一相关的,如果file是一个字符串。如果TRUE,输出追加到文件。如果FALSE,任何现有文件的名称被摧毁。


参数:quote
a logical value (TRUE or FALSE) or a numeric vector.  If TRUE, any character or factor columns will be surrounded by double quotes.  If a numeric vector, its elements are taken as the indices of columns to quote.  In both cases, row and column names are quoted if they are written.  If FALSE, nothing is quoted.
一个逻辑值(TRUE或FALSE)或数字向量。如果TRUE,任何字符或因素列将用双引号包围。如果一个数值向量,其元素为引用的列的索引。在这两种情况下,行和列名报价,如果他们被写入。如果FALSE,并没有被引用。


参数:sep
the field separator string.  Values within each row of x are separated by this string.
字段分隔符字符串。 x行内每个值这个字符串分隔。


参数:eol
the character(s) to print at the end of each line (row). For example, eol="\r\n" will produce Windows' line endings on a Unix-alike OS, and eol="\r" will produce files as expected by Excel:mac 2004.
(S)的字符打印在每一行(列)。例如,eol="\r\n"会产生一个Unix相似的操作系统Windows的行结尾,和eol="\r"会产生文件用Excel预计:2004年MAC。


参数:na
the string to use for missing values in the data.
使用中的数据丢失值的字符串。


参数:dec
the string to use for decimal points in numeric or complex columns: must be a single character.
使用数字或复杂的列小数点的字符串必须是一个字符。


参数:row.names
either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written.
无论是逻辑值,指出是否行名xx要写入,或要写入的字符向量的行名。


参数:col.names
either a logical value indicating whether the column names of x are to be written along with x, or a character vector of column names to be written.  See the section on "CSV files" for the meaning of col.names = NA.
无论是逻辑值,指出是否列名xx要写入,或要写入的列名的特征向量。见节为col.names = NA意义上的“CSV文件”。


参数:qmethod
a character string specifying how to deal with embedded double quote characters when quoting strings.  Must be one of "escape" (default for write.table), in which case the quote character is escaped in C style by a backslash, or "double" (default for write.csv and write.csv2), in which case it is doubled.  You can specify just the initial letter.
一个字符串,指定引用字符串时如何处理与嵌入式双引号字符。必须是一个"escape"(默认为write.table),在这种情况下,在C风格的转义引号字符由一个反斜杠,或"double"(write.csv“默认的 write.csv2),在这种情况下增加一倍。您可以指定只的首字母。


参数:fileEncoding
character string: if non-empty declares the encoding to be used on a file (not a connection) so the character data can be re-encoded as they are written.  See file.
字符串:如果非空的声明文件(未连接)使用的字符数据,所以可以被重新编码为他们写的编码。看到file。


参数:...
arguments to write.table: append, col.names, sep, dec and qmethod cannot be altered.  
write.table参数:append,col.names,sep,dec和qmethod不能被改变。


Details

详情----------Details----------

If the table has no columns the rownames will be written only if row.names=TRUE, and vice versa.
如果表中有没有列在rownames将被写入只有row.names=TRUE,反之亦然。

Real and complex numbers are written to the maximal possible precision.
实数和复数的书面最大可能的精度。

If a data frame has matrix-like columns these will be converted to multiple columns in the result (via as.matrix) and so a character col.names or a numeric quote should refer to the columns in the result, not the input.  Such matrix-like columns are unquoted by default.
如果一个数据框有类似矩阵列,这些将被转换为多个列中的结果(通过as.matrix),所以一个字符col.names或数字quote应该是指在列的结果,而不是输入。这种类似矩阵的列默认情况下,未加引号。

Any columns in a data frame which are lists or have a class (e.g. dates) will be converted by the appropriate as.character method: such columns are unquoted by default.  On the other hand, any class information for a matrix is discarded and non-atomic (e.g. list) matrices are coerced to character.
这些列默认情况下,加引号:在一个数据框,这是名单或有一类(如日期),将转换成相应的as.character方法中的任何列。另一方面,任何一个矩阵类的信息将被丢弃和非原子(如列表)矩阵强迫性格。

Only columns which have been converted to character will be quoted if specified by quote.
如果指定quote只列已转换为字符将被引用。

The dec argument only applies to columns that are not subject to conversion to character because they have a class or are part of a matrix-like column (or matrix), in particular to columns protected by I().  Use options("OutDec") to control such conversions.
dec参数只适用于不须转换为字符列,因为他们有一个类或者是一个矩阵像列(或矩阵)特别I()保护的列,一部分。使用options("OutDec")控制这种转换。

In almost all cases the conversion of numeric quantities is governed by the option "scipen" (see options), but with the internal equivalent of digits=15.  For finer control, use format to make a character matrix/data frame, and call write.table on that.
在几乎所有情况下,数字量的转换是由选项"scipen"(看到options),但与内部等效digits=15的。为更好的控制,使用format字符矩阵/数据框,并调用write.table,。

These functions check for a user interrupt every 1000 lines of output.
检查这些功能为用户中断每1000行的输出。

If file is a non-open connection, an attempt is made to open it and then close it after use.
如果file是一个非公开的连接,试图打开它,然后使用后关闭。

To write a Unix-style file on Windows, use a binary connection e.g. file = file("filename", "wb").
写在Windows的Unix风格的文件,使用二进制的连接,例如file = file("filename", "wb")。


CSV文件----------CSV files----------

By default there is no column name for a column of row names.  If col.names = NA and row.names = TRUE a blank column name is added, which is the convention used for CSV files to be read by spreadsheets.  Note that such CSV files can be read in R by
默认情况下,有没有一列列名的列名。如果col.names = NA和row.names = TRUE添加一个空白列名,这是使用CSV文件的约定,由电子表格读取。请注意,这种CSV文件可以在R读取


注意----------Note----------

write.table can be slow for data frames with large numbers (hundreds or more) of columns: this is inevitable as each column could be of a different class and so must be handled separately.  If they are all of the same class, consider using a matrix instead.
write.table可以是缓慢的大量列(数百或更多)的数据框:这是不可避免的,每列可能是一个不同的类,所以一定要分开处理。如果他们是同一类的所有,而不是考虑使用一个矩阵。


参见----------See Also----------

The "R Data Import/Export" manual.
“R数据导入/导出”手册。

read.table, write.
read.table,write。

write.matrix in package MASS.
write.matrix包MASS。


举例----------Examples----------


## Not run: [#无法运行:]
## To write a CSV file for input to Excel one might use[#写一个CSV文件输入到Excel一可能使用]
x <- data.frame(a = I("a \" quote"), b = pi)
write.table(x, file = "foo.csv", sep = ",", col.names = NA,
            qmethod = "double")
## and to read this file back into R one needs[#读取此文件到R需要]
read.table("foo.csv", header = TRUE, sep = ",", row.names = 1)
## NB: you do need to specify a separator if qmethod = "double".[#注:你需要指定一个分隔符,如果qmethod =“双规”。]

### Alternatively[##另外]
write.csv(x, file = "foo.csv")
read.csv("foo.csv", row.names = 1)
## or without row names[#或无行名]
write.csv(x, file = "foo.csv", row.names = FALSE)
read.csv("foo.csv")

## To write a file in MacRoman for simple use in Mac Excel 2004/8[#写简单的使用在Mac的Excel 2004/8号文件中的MacRoman]
write.csv(x, file = "foo.csv", fileEncoding = "macroman")
## or for Windows Excel 2007/10[#或Excel for Windows中2007/10]
write.csv(x, file = "foo.csv", fileEncoding = "UTF-16LE")


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 05:40 , Processed in 0.022202 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表