shankar-17 wrote:
> 
> Hello,
> I am working multiple simulated data sets with missing values, I would  
> like to store these data sets in either tab delimited format for .csv  
> format with missing values marked as NaN's instead of NA's.
> 
> I read the import/export document which mentions that write.table  
> command converts NaN's to NA. Is there any other way I can store the  
> NaN's. I tried the write syntax it gives me error codes.
> Each data files are of dimensions 1000 x 21 .
> 
> I would appreciate any help in this regard.
> 
> Many thanks
> 

> 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.

-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-tp1679673p1679844.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