[R] write.table() with "numeric" and "complex" data

Cyril Humbert humbertc at univ-mlv.fr
Thu Jan 16 14:30:04 CET 2003


write.table() seems to write "numeric" data as "complex"
if one column of the data.frame is "complex". Is it a 
way to avoid this ?

For example:

> df <- data.frame(x=c(1,2), z=c(1i+1, 2i+2))
> df
	  x    z
	1 1 1+1i
	2 2 2+2i

> mode(df$x)
	[1] "numeric"

> write.table(df, file="aa.dat") 
> df<-read.table("aa.dat", header=TRUE)
> df
	     x    z
	1 1+0i 1+1i
	2 2+0i 2+2i

> mode(df$x)
	[1] "complex"

> version                  
	platform i386-pc-linux-gnu
	major    1                
	minor    6.2              


Thanks

-- 
Cyril




More information about the R-help mailing list