R: 带引号的 read.table

Ani*_*ita 2 r

我有以下结构,保存在 txt.file 中:

" punc "
x nounsg x
" punc "
" punc "
artikel nounsg "
" punc "
Run Code Online (Sandbox Code Playgroud)

我想将这个 txt.file 读入 R,所以我试过这个

read.table("pos.txt",header=F, sep=" ")
Run Code Online (Sandbox Code Playgroud)

但是这个在 R 中的产量:

"tpunc\t"
x\tnounsg\tx
"\tpunc\t
"\tpunc\t
artikel\tnounsg\tartikel
"\tpunc\t"
Run Code Online (Sandbox Code Playgroud)

我想要一个有 3 列和 6 行的矩阵。这怎么可能?

当我添加fill = TRUE并使用时,sep = "\t",我得到:

 \tpunc\t             x                  \tpunc\t
 \tpunc\t             artikel            \tpunc\t 
Run Code Online (Sandbox Code Playgroud)

所以有一些信息丢失

> readLines("pos.txt")[1:2]
[1] "\"\tpunc\t\""             "artikel\tnounsg\tartikel"
Run Code Online (Sandbox Code Playgroud)

B.S*_*kar 8

看看这是不是你想要的:

 data <- read.table(file = "pos.txt", quote = "")
Run Code Online (Sandbox Code Playgroud)

引号设置为"并且'默认为read.table。从您的问题来看,我认为您正试图将它们视为普通数据元素。因此,将引号设置为空字符。