设为首页收藏本站获取积分奖励

R语言中文网

 找回密码
 立即注册
查看: 703|回复: 0

R语言数据输入read.table()函数-中英文对照帮助文档

[复制链接]
发表于 2020-8-21 08:11:56 | 显示全部楼层 |阅读模式
        R语言数据输入read.table()函数-中英文对照帮助文档

                                         By MicroRbt Martinez PhD

R语言函数名:read.table()
R语言函数功能:数据输入
来自资源库:基础库(R语言自带)
read.table()函数所属R语言包:所在R包具体名称、包功能的中英文双语描述见正文后面'--所在R语言包信息--'部分。

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

Reads a file in table format and creates a data frame from it, with cases corresponding to lines and variables to fields in the file.
读取表格式的文件并从中创建一个数据框,其大小写与文件中字段的行和变量相对应。


使用方法-----Usage-----

read.table(file, header = FALSE, sep = "", quote = "\"'",
dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"),
row.names, col.names, as.is = !stringsAsFactors,
na.strings = "NA", colClasses = NA, nrows = -1,
skip = 0, check.names = TRUE, fill = !blank.lines.skip,
strip.white = FALSE, blank.lines.skip = TRUE,
           comment.char = "#",",
”,

allowEscapes = FALSE, flush = FALSE,
stringsAsFactors = default.stringsAsFactors(),
fileEncoding = "", encoding = "unknown", text, skipNul = FALSE)
read.csv(file, header = TRUE, sep = ",", quote = "\"",
dec = ".", fill = TRUE, comment.char = "", ...)
read.csv2(file, header = TRUE, sep = ";", quote = "\"",
dec = ",", fill = TRUE, comment.char = "", ...)
read.delim(file, header = TRUE, sep = "\t", quote = "\"",
dec = ".", fill = TRUE, comment.char = "", ...)
read.delim2(file, header = TRUE, sep = "\t", quote = "\"",
dec = ",", fill = TRUE, comment.char = "", ...)

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

参数file介绍: the name of the file which the data are to be read from. Each row of the table appears as one line of the file. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). Tilde-expansion is performed where supported. This can be a compressed file (see file).
要从中读取数据的文件的名称。表格的每一行显示为文件的一行。如果它不包含absolute路径,则文件名为当前工作目录getwd()的relative。在支持的情况下执行波浪扩展。这可以是压缩文件(请参阅file)。

Alternatively, file can be a readable text-mode connection (which will be opened for reading if necessary, and if so closed (and hence destroyed) at the end of the function call). (If stdin() is used, the prompts for lines may be somewhat confusing. Terminate input with a blank line or an EOF signal, Ctrl-D on Unix and Ctrl-Z on Windows. Any pushback on stdin() will be cleared before return.)
另外,file可以是可读的文本模式连接(必要时将打开以进行读取,如果这样,则在函数调用的末尾打开closed(并因此销毁))。 (如果使用了stdin(),则行的提示可能会有些混乱。用空行或EOF信号终止输入,在Unix上为Ctrl-D,在Windows上为Ctrl-Z。在返回之前,将清除stdin()上的任何推回。)

file can also be a complete URL. (For the supported URL schemes, see the URLs section of the help for url.)
file也可以是完整的URL。 (有关受支持的URL方案,请参阅url的帮助中的URLs部分。)

参数header介绍: a logical value indicating whether the file contains the names of the variables as its first line. If missing, the value is determined from the file format: header is set to TRUE if and only if the first row contains one fewer field than the number of columns.
一个逻辑值,指示文件是否包含变量名称作为其第一行。如果缺失,则从文件格式确定该值:当且仅当第一行包含的字段少于列数时,才将header设置为TRUE。

参数sep介绍: the field separator character. Values on each line of the file are separated by this character. If sep = "" (the default for read.table) the separator is white space , that is one or more spaces, tabs, newlines or carriage returns.
字段分隔符。文件每一行上的值都用此字符分隔。如果sep = ""(read.table的默认值),则分隔符为white space,即一个或多个空格,制表符,换行符或回车符。

参数quote介绍: the set of quoting characters. To disable quoting altogether, use quote = "". See scan for the behaviour on quotes embedded in quotes. Quoting is only considered for columns read as character, which is all of them unless colClasses is specified.
引号字符集。要完全禁用引用,请使用quote = ""。有关嵌入在引号中的引号的行为,请参见scan。仅对读取为字符的列考虑报价,除非指定了colClasses,否则所有列均被引用。

参数dec介绍: the character used in the file for decimal points.
文件中用于小数点的字符。

参数numerals介绍: string indicating how to convert numbers whose conversion to double precision would lose accuracy, see type.convert. Can be abbreviated. (Applies also to complex-number inputs.)
字符串,指示如何将数字转换为转换为双精度会丢失精度的数字,请参见type.convert。可以缩写。 (也适用于复数输入。)

参数row.names介绍: a vector of row names. This can be a vector giving the actual row names, or a single number giving the column of the table which contains the row names, or character string giving the name of the table column containing the row names.
行名的向量。这可以是给出实际行名的向量,也可以是给出包含行名的表的列的单个数字,也可以是给出包含行名的表列的名称的字符串。

If there is a header and the first row contains one fewer field than the number of columns, the first column in the input is used for the row names. Otherwise if row.names is missing, the rows are numbered.
如果有标题,并且第一行包含的字段少于列数,则输入中的第一列用作行名。否则,如果缺少row.names,则会对行进行编号。

Using row.names = NULL forces row numbering. Missing or NULL row.names generate row names that are considered to be automatic (and not preserved by as.matrix).
使用row.names = NULL强制行编号。缺少或NULL row.names会生成被视为automatic的行名(并且as.matrix不会保留)。

参数col.names介绍: a vector of optional names for the variables. The default is to use "V" followed by the column number.
变量的可选名称的向量。默认值是使用"V",后跟列号。

参数as.is介绍: controls conversion of character variables (insofar as they are not converted to logical, numeric or complex) to factors, if not otherwise specified by colClasses. Its value is either a vector of logicals (values are recycled if necessary), or a vector of numeric or character indices which specify which columns should not be converted to factors.
如果colClasses另有规定,则控制将字符变量(因
-----未完,待续-----,↓↓↓展开剩余72%↓↓↓
购买主题 前行需要您的支持,请赞助作者 【15 金钱】 就能浏览全部100%内容啦!(本贴一次赞助、永久可读)
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|Archiver|R语言中文网    

GMT+8, 2024-5-21 05:53 , Processed in 0.027544 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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