write.table没有用标签分隔内容?

时间:2017-03-27 14:40:07

标签: r

我目前正在尝试修改文件,然后将其保存在R. 我遇到的问题是保存它,内容不是标签分隔,我不确定我明白为什么?

这是代码:

phones <- read.table("/home/k/kaldi-trunk/egs/deltas/s5/data/lang/phones.txt", quote="\"")
ctm <- read.table("/home/k/kaldi-trunk/egs/deltas/s5/exp/align_test/phones.ctm", quote="\"")

names(ctm) <- c("file_name","prob","start","end","id")
ctm$file <- gsub("_[0-9]*$","",ctm$file_name)
names(phones) <- c("phone","id")


ctm2 <- merge(ctm, phones, by="id")
ctm3 <- ctm2[,-1]
ctm3 <- ctm3[,-5]
ctm3 <- ctm3[with(ctm3,order(ctm3$file_name , ctm3$start)),]
ctm4 <- ctm3[1:nrow(ctm3),1:ncol(ctm3)]
write.table(ctm4, "/home/k/kaldi-trunk/egs/deltas/s5/data/align_test/phones.txt",col.names = F , row.names=F, quote=F, sep="\t")

ctm4就像这样:

fbbh-b-an86 1   0   0.33    <SIL>
fbbh-b-an86 1   0.33    0.21    S_B
fbbh-b-an86 1   0.54    0.2 IY_E
fbbh-b-an86 1   0.74    0.16    Z_B
fbbh-b-an86 1   0.9 0.29    IY_E
fbbh-b-an86 1   1.19    0.21    D_B
fbbh-b-an86 1   1.4 0.34    IY_E

为什么有些行标签分开而有些则没有。

输入是空间中的ctm

fbbh-b-an86 1 0.000 0.330 1
fbbh-b-an86 1 0.330 0.210 110
fbbh-b-an86 1 0.540 0.200 71
fbbh-b-an86 1 0.740 0.160 138
fbbh-b-an86 1 0.900 0.290 71
fbbh-b-an86 1 1.190 0.210 38
fbbh-b-an86 1 1.400 0.340 71

phones也是空格分隔的:

<eps> 0
<SIL> 1
<SIL>_B 2
<SIL>_E 3
<SIL>_I 4
<SIL>_S 5
AA_B 6
AA_E 7
AA_I 8
AA_S 9
AE_B 10

那么为什么输出不是制表符分隔,即使在write.table中指定它应该用制表符分隔?

0 个答案:

没有答案