read.fortran(utils)
read.fortran()所属R语言包:utils
Read Fixed-Format Data
读取固定格式的数据
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Read fixed-format data files using Fortran-style format specifications.
读取固定格式的数据文件,使用Fortran风格的格式规范。
用法----------Usage----------
read.fortran(file, format, ..., as.is = TRUE, colClasses = NA)
参数----------Arguments----------
参数:file
File or connection to read from
读取文件或连接
参数:format
Character vector or list of vectors. See "Details" below.
向量的特征向量或列表。请参阅下面的“详细资料”。
参数:...
Other arguments for read.fwf
其他参数read.fwf
参数:as.is
Keep characters as characters?
保持字符的字符?
参数:colClasses
Variable classes to override defaults. See read.table for details.
变量类来覆盖默认值。看到read.table详情。
Details
详情----------Details----------
The format for a field is of one of the following forms: rFl.d, rDl.d, rXl, rAl, rIl, where l is the number of columns, d is the number of decimal places, and r is the number of repeats. F and D are numeric formats, A is character, I is integer, and X indicates columns to be skipped. The repeat code r and decimal place code d are always optional. The length code l is required except for X formats when r is present.
字段的格式是下列形式之一:rFl.d,rDl.d,rXl,rAl,rIl,其中l列数,d是小数位数,和r是重复的次数。 F和D数字格式,A是字符,I是整数,X表示要跳过的列。重复代码r和小数位代码d总是可选的。长度代码l当X格式r是目前除需要。
For a single-line record, format should be a character vector. For a multiline record it should be a list with a character vector for each line.
单行记录,format应该是一个特征向量。对于一个多行记录,它应该是为每行的字符向量列表。
Skipped (X) columns are not passed to read.fwf, so colClasses, col.names, and similar arguments passed to read.fwf should not reference these columns.
跳过(X)列没有传递给read.fwf,所以colClasses,col.names,传递read.fwf不应该引用这些列的类似的论据。
值----------Value----------
A data frame
数据框
注意----------Note----------
read.fortran does not use actual Fortran input routines, so the formats are at best rough approximations to the Fortran ones. In particular, specifying d > 0 in the F or D format will shift the decimal d places to the left, even if it is explicitly specified in the input file.
read.fortran不使用实际的Fortran输入例程,所以在格式的Fortran的最好的粗糙近似。特别是,指定d > 0F或D格式将小数d地方转移到左侧,即使是在输入文件中明确指定。
参见----------See Also----------
read.fwf, read.table, read.csv
read.fwf,read.table,read.csv
举例----------Examples----------
ff <- tempfile()
cat(file=ff, "123456", "987654", sep="\n")
read.fortran(ff, c("F2.1","F2.0","I2"))
read.fortran(ff, c("2F1.0","2X","2A1"))
unlink(ff)
cat(file=ff, "123456AB", "987654CD", sep="\n")
read.fortran(ff, list(c("2F3.1","A2"), c("3I2","2X")))
unlink(ff)
# Note that the first number is read differently than Fortran would[请注意,第一个数字是比Fortran语言将不同的阅读]
# read it:[阅读:]
cat(file=ff, "12.3456", "1234567", sep="\n")
read.fortran(ff, "F7.4")
unlink(ff)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|