Reputation: 789
I've got the following structure, saved in a txt.file:
" punc "
x nounsg x
" punc "
" punc "
artikel nounsg "
" punc "
I would like to read this txt.file into R, so I've tried this with
read.table("pos.txt",header=F, sep=" ")
but this yield in R:
"tpunc\t"
x\tnounsg\tx
"\tpunc\t
"\tpunc\t
artikel\tnounsg\tartikel
"\tpunc\t"
I would like to have a matrix with 3 columns and 6 rows instead. How could this be done?
When I add fill = TRUE
and use sep = "\t",
then I get:
\tpunc\t x \tpunc\t
\tpunc\t artikel \tpunc\t
So there is some information lost
> readLines("pos.txt")[1:2]
[1] "\"\tpunc\t\"" "artikel\tnounsg\tartikel"
Upvotes: 3
Views: 14587
Reputation: 1281
See if this is what you want:
data <- read.table(file = "pos.txt", quote = "")
Quotes are set to "
and '
by default for read.table
. From your question, I think you are trying to treat them as ordinary data elements. So, set the quote to empty character.
Upvotes: 9