[R] retaining characters in a csv file
murdoch.duncan at gmail.com
Wed Sep 23 02:40:03 CEST 2015
On 22/09/2015 7:19 PM, peter dalgaard wrote:
>> 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
> 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.
It specifically does not. Quotes allow commas and spaces to be ignored
as column separators. That's all. They say nothing about the type of data.
> 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.
More information about the R-help