Skip to content
Prev 85547 / 398506 Next

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

Thank you very much! I wonder why I did not yet come across that function format(). Guess this won ??t be the last time that I use it. The following did exactly what I was looking for:

temp<-attributes(jjmat)

jjmat<-format(jjmat, decimal.mark=",")

attributes(jjmat)<-temp

With these changes jjmat was perfect for export to excel.


-----Urspr??ngliche Nachricht-----
Von: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Gesendet: Mittwoch, 1. Februar 2006 16:31
An: Michael Reinecke
Cc: R-help at stat.math.ethz.ch
Betreff: Re: [R] Write.table: change points to commas when object contains a row of characters

You cannot have a matrix or a data frame which is partially numeric and partially character (within a column for a data frame).  You seem rather to have a list matrix.  Then ?write.table does say

      Any columns in a data frame which are lists or have a class (e.g.
      dates) will be converted by the appropriate 'as.character' method:
      such columns are unquoted by default.  On the other hand, any
      class information for a matrix is discarded.

Although it does not say so, the same happens with a matrix.

You need to get a table before you try outputting it: I suggest using
format() to help you.
On Wed, 1 Feb 2006, Michael Reinecke wrote: