您的位置:首页 > 其它

读入外部文件

2015-11-24 17:43 267 查看

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="\"")


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: