From tomk at 0xdata.com  Sat Apr 26 22:12:09 2014
From: tomk at 0xdata.com (Tom Kraljevic)
Date: Sat, 26 Apr 2014 13:12:09 -0700
Subject: [Rd] Please make Pre-3.1 read.csv (type.convert) behavior
	available
In-Reply-To: <CD8BE0B1-B423-4A78-999D-150B9543E4B4@0xdata.com>
References: <D56A602D-9044-400D-B12A-196A5EAEC05D@0xdata.com>
	<535B9868.8040700@gmail.com>
	<21339.42501.466132.822224@max.nulle.part>
	<CD8BE0B1-B423-4A78-999D-150B9543E4B4@0xdata.com>
Message-ID: <2E36E30E-424B-4CC4-BA9C-6AEC2AAFB340@0xdata.com>


Hi,


One additional follow-up here.

Unfortunately, I hit what looks like an R parsing bug that makes the Java Double.toHexString() output
unreliable for reading by R.  (This is really unfortunate, because the format is intended to be lossless
and it looks like it?s so close to fully working.)

You can see the spec for the conversion here:
    http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#toHexString(double)

The last value in the list below is not parsed by R in the way I expected, and causes the column to flip 
from numeric to factor.


-0x1.8ff831c7ffffdp-1
-0x1.aff831c7ffffdp-1
-0x1.bff831c7ffffdp-1
-0x1.cff831c7ffffdp-1
-0x1.dff831c7ffffdp-1
-0x1.eff831c7ffffdp-1
-0x1.fff831c7ffffdp-1           <<<<< this value is not parsed as a number and flips the column from numeric to factor.


Below is the R output from adding one row at a time to ?bad.csv?.
The last attempt results in a factor rather than a numeric column.

What?s really odd about it is that the .a through .e case work fine but the .f case doesn?t.


Thanks,
Tom


> bad.df = read.csv(file="/Users/tomk/bad.csv", header=F)
> str(bad.df)
'data.frame':	1 obs. of  1 variable:
 $ V1: num -0.781
> bad.df = read.csv(file="/Users/tomk/bad.csv", header=F)
> str(bad.df)
'data.frame':	2 obs. of  1 variable:
 $ V1: num  -0.781 -0.844
> bad.df = read.csv(file="/Users/tomk/bad.csv", header=F)
> str(bad.df)
'data.frame':	3 obs. of  1 variable:
 $ V1: num  -0.781 -0.844 -0.875
> bad.df = read.csv(file="/Users/tomk/bad.csv", header=F)
> str(bad.df)
'data.frame':	4 obs. of  1 variable:
 $ V1: num  -0.781 -0.844 -0.875 -0.906
> bad.df = read.csv(file="/Users/tomk/bad.csv", header=F)
> str(bad.df)
'data.frame':	5 obs. of  1 variable:
 $ V1: num  -0.781 -0.844 -0.875 -0.906 -0.937
> bad.df = read.csv(file="/Users/tomk/bad.csv", header=F)
> str(bad.df)
'data.frame':	6 obs. of  1 variable:
 $ V1: num  -0.781 -0.844 -0.875 -0.906 -0.937 ...
> bad.df = read.csv(file="/Users/tomk/bad.csv", header=F)
> str(bad.df)
'data.frame':	7 obs. of  1 variable:
 $ V1: Factor w/ 7 levels "-0x1.8ff831c7ffffdp-1",..: 1 2 3 4 5 6 7



[Rd] Please make Pre-3.1 read.csv (type.convert) behavior available
Tom Kraljevic