From P.Dalgaard at biostat.ku.dk  Wed Dec  2 13:55:40 2009
From: P.Dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Wed, 02 Dec 2009 13:55:40 +0100
Subject: [Rd] read.csv confused by newline characters in header
	(PR#14103)
In-Reply-To: <20091202095512.7F00E2831FFB@mail.pubhealth.ku.dk>
References: <20091202095512.7F00E2831FFB@mail.pubhealth.ku.dk>
Message-ID: <4B1663CC.4060206@biostat.ku.dk>

g.russell at eos-solutions.com wrote:
> Full_Name: George Russell
> Version: 2.10.0
> OS: Microsoft Windows XP Service Pack 2
> Submission from: (NULL) (217.111.3.131)
> 
> 
> The following code (typed into R --vanilla)
> 
> testString <- '"B1\nB2"\n1\n'
> con <- textConnection(testString)
> tab <- read.csv(con,stringsAsFactors = FALSE)
> 
> produces a data frame with with one row and one column; the name of the column
> is "B1.B2" (alright so far). However according to
> print(tab[[1,1]])
> 
> the value of the entry in the first row and first column is
> 
> "B2\n1\n"
> 
> So B2 has somehow got into both the names of the data frame and its entry.
> Either R is confused or I am. What is going on?

Presumably, read.table is not obeying quotes when removing what it
thinks is the header line. Another variation is this:

> tab <- read.table(stdin(), head=T)
0: "B1
0: B2"
1: 1
2:
> tab
  B1.B2
1   B2"
2     1


It's somehow connected to the

pushBack(c(lines, lines), file)

bits in readtable.R, but I don't quite get it.

-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



[Rd] read.csv confused by newline characters in header (PR#14103)
Peter Dalgaard