Delimited files(符号分割文件)
*based on the read.table()function
read.table(file, header, sep = , quote = , dec = , row.names, col.names,as.is = , na.strings , colClasses , nrows =, skip = ,check.names = , fill = , strip.white = , blank.lines.skip = ,comment.char = , allowEscapes = , flush = , stringsAsFactors = ,encoding = )
sep 假定每个字段之间都有一个分隔符:例如有一个文件top.5.salsries.csv,内容如下:
name.last,name.first,team,position,salary
“Manning”,”Peyton”,”Colts”,”QB”,18700000
“Brady”,”Tom”,”Patriots”,”QB”,14626720
“Pepper”,”Julius”,”Panthers”,”DE”,14137500
“Palmer”,”Carson”,”Bengals”,”QB”,13980000
“Manning”,”Eli”,”Giants”,”QB”,12916666
上例中,文本字段都是有引号的,每个字段由逗号分割。假定该文件在当前目录下,读取该文件:
top.5.salaries <- read.table("top.5.salaries.csv", header=TRUE, sep=",", quote="\"")