Re: [R] Handling of tables in R

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 19 Aug 2005 - 21:15:48 EST

On Fri, 19 Aug 2005, Prof Brian Ripley wrote:

> On Fri, 19 Aug 2005, Romain Francois wrote:
>
>> Le 19.08.2005 11:22, Anne a écrit :
>>
>>> Save your table in a text file ( see ?write.table ) with the separator
>>> set to "\t" ; you can then import it into excel
>>>
>>> for the nb of digits use
>>>> options(digits=3)
>
> Only for printing in R: see below for other suggestions.
>
>> And if you run R on windows (just a guess because you didn't tell), the
>> saving-to-a-file part is not necessary. use :
>> R> write.table(your.data.frame, file='clipboard')
>> and on excel "paste", your data should magically appear on excel ...
>
> You are likely to be better off with write.csv(). There _is_ a manual (`R
> Data Import/Export') about this. (In particular, the default setting for
> col.names in write.table is not usually what Excel usually expects, and the
> default separator is space, so you better not have spaces (or for Anne's
> suggestion, tabs) in the data.)

Peter Dalgaard pointed out that write.table defaults to quoting, so it is quotes in fields that would be a problem not tabs/spaces. However, write.csv() is set up with the correct options for that, and also for the header line if row names are written (the default).

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ 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 Fri Aug 19 21:21:57 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:33:36 EST