Rolf Turner wrote:
> 
> 
> On 24/03/2010, at 12:34 PM, Sharpie wrote:
>>> foo <- matrix(0,nrow=3,ncol=3)
>>> foo
>>     [,1] [,2] [,3]
>> [1,]    0    0    0
>> [2,]    0    0    0
>> [3,]    0    0    0
>> 
>>> foo[3,3] <- NA
>>> foo
>>     [,1] [,2] [,3]
>> [1,]    0    0    0
>> [2,]    0    0    0
>> [3,]    0    0   NA
>> 
>>> write.csv( foo, file='tst.csv', na = "NaN", row.names = F )
>>> readLines( 'tst.csv' )
>> [1] "\"V1\",\"V2\",\"V3\"" "0,0,0"                "0,0,0"
>> [4] "0,0,NaN"
>> 
>> Seems to work fine for me.  If you post a reproducible example, we could
>> probably figure out why it is not working for you.
> 
> 
> This doesn't work if you have both NAs and NaNs in your data frame and you
> want to distinguish between these.  I.e. when you read the data back in,
> all NAs will have been converted to NaNs.
> 
> Admittedly the OP said he wanted to represent all NAs as NaNs, so your
> solution would seem to work for him.
> 
>       cheers,
> 
>               Rolf Turner
> 


Aye, it still works if I replace the NA in my matrix with NaN.  If there is
a mixture of NAs and NaNs, there will be some loss of distinction as you
say.

However, I can not tell if this is the case from the original post-- hence
the need for an example!

-Charlie

-----
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://n4.nabble.com/Saving-tab-csv-delimited-data-with-NaN-s-tp1679673p1679909.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to