Created attachment 1715 [details]
Fix NaN/NA serializing/deserializing.
When saving in ASCII format, both NA and NaN real values are serialized as NA. This looks to be a rather old R issue.
> x = c( 1.0, NA, NaN )
> save( x, file = "na_test.RData", ascii = TRUE )
> load( file = "na_test.RData" )
 1 NA NA
Attached is the patch that serializes NA as "NA" and NaN as "NaN" and adds "NaN" deserialization. However, files saved with this patch should be backward-compatible with the unpatched R versions as "NaN" is recognized by sscanf(buf, "%lg", &d).
Thank you for the careful concise example and quality patch!!
I'm commiting the fix for this to both R-devel (to be 3.2.0) and R-patched (3.1.2 patched).