[R] error in saved .csv

Peter Langfelder peter.langfelder at gmail.com
Tue Mar 1 23:24:28 CET 2011


On Tue, Mar 1, 2011 at 1:36 PM, Tamas Barjak <tamas.barjak02 at gmail.com> wrote:
> Help me please!
>
> I would like to be saved a data table:
>
> write.csv(random.t1, "place", dec=",", append = T, quote = FALSE, sep = " ",
> qmethod = "double", eol = "\n", row.names=F)
>
> It's OK!
>
> But the rows of file

>  1,1,21042,-4084.87179487179,2457.66483516483,-582.275562799881
> 2,2,23846,-6383.86480186479,-3409.98451548449,-3569.72145340269
> and no
>
> 1
> 21042 -         4084.87179487179 2457.66483516483
> Not proportional...
>
> What's the problem???

If I understand you correctly, you want a text file where the
separator is a white space. You cannot get that with write.csv - you
have to use write.table(). The function write.csv does not allow you
to change the sep argument. Here's what the help file says:

 ‘write.csv’ and ‘write.csv2’ provide convenience wrappers for
     writing CSV files.  They set ‘sep’, ‘dec’ and ‘qmethod’, and
     ‘col.names’ to ‘NA’ if ‘row.names = TRUE’ and ‘TRUE’ otherwise.

     ‘write.csv’ uses ‘"."’ for the decimal point and a comma for the
     separator.

     ‘write.csv2’ uses a comma for the decimal point and a semicolon
     for the separator, the Excel convention for CSV files in some
     Western European locales.

     These wrappers are deliberately inflexible: they are designed to
     ensure that the correct conventions are used to write a valid
     file.  Attempts to change ‘append’, ‘col.names’, ‘sep’, ‘dec’ or
     ‘qmethod’ are ignored, with a warning.



More information about the R-help mailing list