Skip to content

Handling of tables in R

7 messages · Fredrik Thuring, PIKAL Petr, Anne +3 more

#
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
see ?options 


Anne


2005/8/19, Fredrik Thuring <frt at codan.dk>:

  
    
#
Le 19.08.2005 11:22, Anne a ??crit :
Hello,

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 ...

Romain

  
    
#
On Fri, 19 Aug 2005, Romain Francois wrote:

            
Only for printing in R: see below for other suggestions.
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.)
?round, ?signif, ?format.  (Anne's answer applies to printing, not to the 
table and not to write.table/csv.)
#
On Fri, 19 Aug 2005, Prof Brian Ripley wrote:

            
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).
#
On Fri, 19 Aug 2005, Fredrik Thuring wrote:
People have told you how to do this for Excel. For SAS you might want to 
try write.foreign() in the "foreign" package, which writes a text file and 
a SAS code file that you can use to read it into SAS.

 	-thomas