[R] retaining characters in a csv file

peter dalgaard pdalgd at gmail.com
Wed Sep 23 01:19:48 CEST 2015


> On 23 Sep 2015, at 00:33 , Rolf Turner <r.turner at auckland.ac.nz> wrote:
> 

[read.csv() doesn't distinguish "123.4" from 123.4]

> IMHO this is a bug in read.csv().
> 

Dunno about that:

pd$ cat ~/tmp/junk.csv 
"1";1
2;"2"
pd$ open !$
open ~/tmp/junk.csv

And lo and behold, Excel opens with 

1 1
2 2

and all cells numeric.

I don't think the CSV standard (if there is one...) specifies that quoted strings are necessarily text.

I think we have been here before, and found that even if we decide that it is a bug (or misfeature), it would be hard to change, because the modus operandi of read.* is to first read everything as character and _then_ see (in type.convert()) which entries can be converted to numeric, logical, etc.

-pd

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list