R read.table 读取表格参数详解

版权声明:欢迎交流:[email protected] https://blog.csdn.net/luo617/article/details/81712886
read.table(file, header = FALSE, sep = "", quote = ""'",
           dec = ".", 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")
header:逻辑参数。指定是否文件第一行为变量名(列名)。
na.strings:指定缺失文字。
skip:指定读数据跳过的行数。
nrows:指定数据读入最大的行数。
dec:指定小数点记号。
sep:指定数据分割字符。
row.names与col.names:赋予数据行名和列名。

读入数据其他相关函数:

readLines():按行读入数据文件。类似perl读数据方式。
scan( ):将数据读作一行向量形式。
read.delim("educ_scores.txt"):读入文本文件(制表符分隔)。
read.csv("educ_scores1.csv"):读入CSV(逗号分割)。
readBin( ):读入二进制数据。
readChar( ):读入字符型数据。
attach( ): 把数据框的变量链接到内存中.

猜你喜欢

转载自blog.csdn.net/luo617/article/details/81712886