read.fwf(utils)
read.fwf()所属R语言包:utils
Read Fixed Width Format Files
读取固定宽度格式文件
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Read a table of fixed width formatted data into a data.frame.
阅读data.frame固定宽度格式的数据表。
用法----------Usage----------
read.fwf(file, widths, header = FALSE, sep = "\t",
skip = 0, row.names, col.names, n = -1,
buffersize = 2000, ...)
参数----------Arguments----------
参数:file
the name of the file which the data are to be read from. Alternatively, file can be a connection, which will be opened if necessary, and if so closed at the end of the function call.
是被读出的数据文件的名称。另外,file可以连接,如有必要,将打开,如果在函数调用结束时关闭。
参数:widths
integer vector, giving the widths of the fixed-width fields (of one line), or list of integer vectors giving widths for multiline records.
整数向量,固定宽度的字段(一条线),或使多行记录的宽度的整数向量的宽度。
参数:header
a logical value indicating whether the file contains the names of the variables as its first line. If present, the names must be delimited by sep.
一个逻辑值,指示是否该文件包含的变量的名称作为其第一线。如果目前的名称必须是分隔sep。
参数:sep
character; the separator used internally; should be a character that does not occur in the file (except in the header).
字符;内部使用的分隔符;应该是一个字符,文件中不发生(在头除外)。
参数:skip
number of initial lines to skip; see read.table.
初始行跳过;看到read.table。
参数:row.names
see read.table.
看到read.table。
参数:col.names
see read.table.
看到read.table。
参数:n
the maximum number of records (lines) to be read, defaulting to no limit.
最大记录数(行)读取,默认没有限制。
参数:buffersize
Maximum number of lines to read at one time
一次读取的最大行数
参数:...
further arguments to be passed to read.table. Useful further arguments include as.is, na.strings, colClasses and strip.white.
进一步的参数被传递到read.table。进一步有用的参数包括as.is,na.strings,colClasses和strip.white。
Details
详情----------Details----------
Multiline records are concatenated to a single line before processing. Fields that are of zero-width or are wholly beyond the end of the line in file are replaced by NA.
多行记录被连接到处理前的一行。领域是零宽度或完全超出了行结束fileNA被替换。
Negative-width fields are used to indicate columns to be skipped, e.g., -5 to skip 5 columns. These fields are not seen by read.table and so should not be included in a col.names or colClasses argument (nor in the header line, if present).
负宽领域,用来表示跳过的列,例如,-5跳过5列。这些领域都没有见过read.table,所以不应包括在col.names或colClasses参数(也不在标题行中,如果存在的话)。
Reducing the buffersize argument may reduce memory use when reading large files with long lines. Increasing buffersize may result in faster processing when enough memory is available.
减少buffersize参数,可以减少内存使用,当读取大文件与长行。增加buffersize时,可能会导致更快的处理速度足够的可用内存。
值----------Value----------
A data.frame as produced by read.table which is called internally.
一个data.frameread.table被称为内部产生。
作者(S)----------Author(s)----------
Brian Ripley for <font face="Courier New,Courier" color="#666666"><b>R</b></font> version: original <code>Perl</code> by Kurt Hornik.
参见----------See Also----------
scan and read.table.
scan和read.table。
举例----------Examples----------
ff <- tempfile()
cat(file=ff, "123456", "987654", sep="\n")
read.fwf(ff, widths=c(1,2,3)) #> 1 23 456 \ 9 87 654[> 1 23 456 \ 9 87 654]
read.fwf(ff, widths=c(1,-2,3)) #> 1 456 \ 9 654[> 1 456 \ 9 654]
unlink(ff)
cat(file=ff, "123", "987654", sep="\n")
read.fwf(ff, widths=c(1,0, 2,3)) #> 1 NA 23 NA \ 9 NA 87 654[> 1不适用23 NA \ 9 NA 87 654]
unlink(ff)
cat(file=ff, "123456", "987654", sep="\n")
read.fwf(ff, widths=list(c(1,0, 2,3), c(2,2,2))) #> 1 NA 23 456 98 76 54[1不适用23 456 98 76 54]
unlink(ff)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|