On Sat, 16 Feb 2008, Alan Zaslavsky wrote: > > If you want to get nicely formatted tables in Word and are familiar with > Office tools (I know it's the Evil Empire but some of us work there), I > suggest that you use Excel for formatting and then insert the table into > your Word document. IMHO, Excel is much superior to Word for table > formatting, e.g. modifying number of significant digits, playing around > with fonts and number formats, etc. And when you have gotten the formats > right you can paste in modified values of the numbers in the table without > having to do the formatting again. Including the table in your Word > document is easy by cut-paste or creating a live link. > > As a user of R under Unix I haven't looked into the facilities for writing > tables to Excel under Windows but there is something there. Alternatively > you can write a fixed-column or tab-delimited file and easily import to > Excel. >
Production of tables and formatting them in Word is something I have dealt with a couple of times recently and it really is important to do something smart because of the time taken to individually format tables. An approach I used recently was to produce a text table in R and export it to Excel as a .csv file which could then be copied as is to Word. Borders and the like would still have to be formatted individually but not entries in the table (with a minor caveat below). The tables comprised results of test with p-values and confidence intervals etc for various variables. To produce the entries in the table I wrote a small function which pasted bits of output together and formatted numbers exactly using formatC. Often the function produced a number of cells at one time. One difficulty I had was Excel deciding as usual that it knew better than I did what I wanted. So when I had a cell with a p-value in brackets, that was of course a negative number for example. My solution was to prepend a ' character which make Excel treat the following characters literally. Once the table has been put in Word a simple search and replace can remove the ' characters. Overall, I was reasonably happy with the approach I took. If I have a future need I will have some ready-made functions to work from which will make life easier. I will be interested to try some of the other suggestions in this thread. David Scott _________________________________________________________________ David Scott Department of Statistics, Tamaki Campus The University of Auckland, PB 92019 Auckland 1142, NEW ZEALAND Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000 Email: [EMAIL PROTECTED] Graduate Officer, Department of Statistics Director of Consulting, Department of Statistics ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.