[R] Write.table: change points to commas when object contains a row of characters

From: Michael Reinecke <Reinecke_at_consultic.com>
Date: Wed 01 Feb 2006 - 22:31:08 EST


Dear Group! I asked write.table to change the decimal point from "." to "," , but apparently it would only do so if the object to be written does not contain any character elements. I would like to understand, why this has to be so and - of course - find a solution for my matrix object jjmat, that I tried to write out by  

write.table(jjmat, file="jjmat.txt", row.names=TRUE, col.names=NA,sep="\t",dec=",")  

I also tried "options(OutDec=",")" , which changes the presentation on the console, but seems to have no influence on write table: jjmat is still written out with points instead of commas.  

The object looks like this:  

> jjmat

         f2a1 f2b1 f5a1 f5b1 f5c1

rowname1 "coltext1" "coltext2" "coltext3" "coltext4" "coltext5"

rowname2 4,428571 4,326531 4,265306 3,959184 3,306122

rowname3 0,469665 0,3328301 0,1776079 -0,1758072 0,0870965

rowname4 4,275862 4,206897 4,137931 3,931034 3,379310  

> deparse(jjmat)

[1] "structure(list(\"coltext1\", 4.42857142857143, 0.469664970752337, "

[2] " 4.27586206896552, \"coltext2\", 4.3265306122449,
0.332830055973803, "

[3] " 4.20689655172414, \"coltext3\", 4.26530612244898,
0.177607859264292, "

[4] " 4.13793103448276, \"coltext4\", 3.95918367346939,
-0.175807245137424, "

[5] " 3.93103448275862, \"coltext5\", 3.30612244897959,
0.087096493847482, "

[6] " 3.37931034482759), .Dim = c(4, 5), .Dimnames =
list(c(\"rowname1\", "

[7] "\"rowname2\", \"rowname3\", \"rowname4\"), c(\"f2a1\", \"f2b1\",
\"f5a1\", "

[8] "\"f5b1\", \"f5c1\")))"
   

Do I have to change the structure of jjmat? Thanks for your comments!  

Greetings,  

Michael

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Feb 01 23:55:14 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:16 EST