ReadData(RSurvey)
ReadData()所属R语言包:RSurvey
Read Data
读取数据
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Reads table formatted data from a connection and creates a data frame from it.
读取表格式的数据从一个连接,并从它创建的数据框。
用法----------Usage----------
ReadData(con, headers = c(FALSE, FALSE, FALSE), sep = "\t",
quote = "\"'", nrows = -1, na.strings = c("", "NA"),
skip = 0, comment.char = "#", encoding = getOption("encoding"))
参数----------Arguments----------
参数:con
connection; a connection object.
连接; connection对象。
参数:headers
logical; a vector of length 3 that indicates whether the data table contains header lines: see "Details".
逻辑的矢量数据表中是否包含标题行的长度为3,表示:“详细信息”。
参数:sep
character; the field separator string. Values on each line of the file are separated by this string.
字符的字段分隔符的字符串。此字符串由被分离的文件中的每一行上的值。
参数:quote
character; the set of quoting characters.
字符的引号字符集。
参数:nrows
integer; the maximum number of rows to read in. Negative and other invalid values are ignored (optional).
整数的最大数量的行读入负和其他无效的值将被忽略(可选)。
参数:na.strings
character; a vector of strings which are interpreted as NA values. Blank fields are also considered to be missing values.
字符一个向量的字符串解释为NA值。空白字段也被视为缺失值。
参数:skip
integer; the number of lines to skip before beginning to read data.
整数;的数目要跳过的行开始读取数据之前。
参数:comment.char
character; a vector of length one containing a single character or an empty string. Use "" to turn off the interpretation of comments altogether.
字符,矢量的长度包含一个单个字符或一个空字符串。使用“完全关闭的解释意见。
参数:encoding
character; encoding to be assumed for input strings. If the value is "latin1" or "UTF-8" it is used to mark character strings as known to be in Latin-1 or UTF-8: it is not used to re-encode the input.
假设输入字符串的字符,编码。如果该值是"latin1"或"UTF-8"它是用来标记字符串的作为已知的Latin-1或UTF-8:它不是用来重新编码输入。
格式----------Format----------
The imported data table requires at least two numeric variables.
导入的数据表至少需要两个数值变量。
Details
详细信息----------Details----------
This function is the primary method for importing table formatted data from a text file. The headers argument, a logical vector of length 3, indicates whether the file contains the names, measurement units, and conversion specification formats of the variables as its initial lines. For example, headers = c(TRUE, FALSE, TRUE) indicates that the first and second lines contain the names and formats of variables, respectively; with measurement units excluded. If headers = c(FALSE, FALSE, FALSE), the default, no header information is contained within the file.
此功能是一个文本文件导入表格式的数据的主要方法。的的headers参数,逻辑向量的长度为3,表示该文件是否包含名称,计量单位和转换规范格式的变量作为其初始行。例如,headers = c(TRUE, FALSE, TRUE)表示的第一和第二行包含的变量的名称和格式,分别与测量单元排除。如果headers = c(FALSE, FALSE, FALSE),默认情况下,没有头信息包含在文件中。
Formats are the character representation of object types used to: identify column classes prior to reading in data, and format values for printing. Conversion specifications are based on C-style string formatting commands for numeric, integer, and character object classes, see sprintf; for example, a format string of "%.5f" applied to the mathematical constant pi results in "3.14159". Calendar date and time objects of class POSIXct are defined by the ISO C99 / POSIX standard, see strftime; for example, "02/26/2010 02:05:39 PM" is represented using "%d/%m/%Y %I:%M:%S %p".
格式是使用的对象类型的字符表示:读入数据之前确定列类,并打印格式值。 numeric,integer和character对象类的C风格字符串的格式化命令转换规范的基础上,sprintf,例如,格式字符串“% 0.5 f“的”3.14159“的数学常数pi结果。日历日期和时间类的对象POSIXctISO C99 / POSIX标准的定义,请参阅“”strftime;例如,“2010年2月26日下午2点○五分39秒”来表示“ %D /%M /%Y%I:%M:%S%P“。
Performance issues associated with reading in large files can be alleviated by specifying formats in a header line, and giving the maximum number of rows to read in.
指定格式的标题行,读取大型文件中的相关的性能问题可以得到缓解,并给予最大的行数读入。
值----------Value----------
Returns a list with the following components:
返回一个列表,与以下组件:
参数:dat
data.frame; a data table with headers and comments removed.
数据框的数据删除表中的页眉和意见。
参数:cols
list; length equal to the current number of data variables. Each component in cols is linked to a specific variable, see ManageData.
的列表上;长度等于数据变量的当前数目。中的每个组件cols链接到一个特定的变量,请参阅ManageData。
参数:vars
list; an initial guess of the state variables. Integer components x, y, z, and t specify the index number in cols that correspond to the respective state variable.
列表状态变量的初始猜测。整数组件x,y,z和t指定索引号cols对应到相应的状态变量。
(作者)----------Author(s)----------
J.C. Fisher
参见----------See Also----------
read.table
read.table
实例----------Examples----------
f <- system.file("extdata/DataExample.txt", package = "RSurvey")
con <- file(f, open = "r", encoding = "latin1")
ans <- ReadData(con, headers = c(TRUE, TRUE, TRUE))
close(con)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|