我想使用读取数据文件
ds <- read.table(file="/data/ken/tmp/tt", header=F,
sep="t", quote=""", dec=".",
fill=T, comment.char="",
stringsAsFactors=F,
colClass=rep("character", 6))
文件tt
如下所示,其中t
作为分隔符
20130129074502thttp://xxx.com.cn/notebook/asus/526600_detail.htmltt5025t526600t255dkmi
但它不起作用:
caution:
In read.table(file = fcon, header = F, sep = "t", quote = """, :
cols = 1 != length(data) = 6
我认为你过于复杂了,试试这个:
read.table(text=tt)
V1 V2 V3 V4 V5
1 2.013013e+13 http://xxx.com.cn/notebook/asus/526600_detail.html 5025 526600 255dkmi
其中tt是:
tt ='20130129074502thttp://xxx.com.cn/notebook/asus/526600_detail.htmltt5025t526600t255dkmi'
编辑
您可以逐行读取,并使用strsplit 进行拆分
sapply(readLines(file.name, n=-1),
function(x) strsplit(gsub('[t|t\]','@',x),'@'))