Hi Everyone,
Recently I got puzzled by the function read.table,
even though I have used it for a long time.
I have such a file (tmp.txt, 2 rows and 3 columns,
with a space among columns):
1 2'-PDE 4
2 3'-PDE 5
if I do:
a = read.table("tmp.txt", header = F, quote = "")
a
V1 V2 V3
1 1 2'-PDE 4
2 2 3'-PDE 5
Everything is fine.
However, if I do:
a = read.table("tmp.txt", header = F)
a
V1 V2 V3
1 2 3'-PDE 5
2 1 2'-PDE 4
3 2 3'-PDE 5
I know it is related to the "quote" as the default
includes '. But how can it get one more row in the
file? Thank you very much for your help in advance!
Jun
Take a look at ?scan. There is an explanation for the doubling of the string Bart Jun Ding wrote:> > Hi Everyone, > > Recently I got puzzled by the function read.table, > even though I have used it for a long time. > > I have such a file (tmp.txt, 2 rows and 3 columns, > with a space among columns): > > 1 2'-PDE 4 > 2 3'-PDE 5 > > if I do: > a = read.table("tmp.txt", header = F, quote = "") > a > V1 V2 V3 > 1 1 2'-PDE 4 > 2 2 3'-PDE 5 > > Everything is fine. > > However, if I do: > a = read.table("tmp.txt", header = F) > a > V1 V2 V3 > 1 2 3'-PDE 5 > 2 1 2'-PDE 4 > 3 2 3'-PDE 5 > > I know it is related to the "quote" as the default > includes '. But how can it get one more row in the > file? Thank you very much for your help in advance! > > Jun > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/A-weird-observation-from-using-read.table-tf4501505.html#a12848830 Sent from the R help mailing list archive at Nabble.com.
Hi Everyone,
Recently I got puzzled by the function read.table,
even though I have used it for a long time.
I have such a file (tmp.txt, 2 rows and 3 columns,
with a space among columns):
1 2'-PDE 4
2 3'-PDE 5
if I do:
a = read.table("tmp.txt", header = F, quote = "")
a
V1 V2 V3
1 1 2'-PDE 4
2 2 3'-PDE 5
Everything is fine.
However, if I do:
a = read.table("tmp.txt", header = F)
a
V1 V2 V3
1 2 3'-PDE 5
2 1 2'-PDE 4
3 2 3'-PDE 5
I know it is related to the "quote" as the default
includes '. But how can it get one more row in the
file? Thank you very much for your help in advance!
Jun