I have just started looking at R, and are getting more and more irritated at myself for not having done that before. However, one of the things I have not found in the documentation is some way of preparing output from R for convenient formatting into something like MS Word. An example: If you use summary(lm(....)) you get nice output. However, if you try to paste that output into the word processor, all the text elements are separated by blanks, and that is not optimal for the creation of a table (in the word processing sense). Is there an option to generate tab-separated output in R ? That would solve the problem. Tom +----------------------------------------------------------------+ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185 Fax : +47-5558-9879 | | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | +----------------------------------------------------------------+
Well, I don't know if it can be used with Word or not, but you might consider Sweave for use with LaTeX. Maybe if you use the sink() command this might work, but I haven't tried it. -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Tom Backer Johnsen Sent: Thursday, February 09, 2006 9:41 AM To: r-help at stat.math.ethz.ch Subject: [R] Tranferring R results to word prosessors I have just started looking at R, and are getting more and more irritated at myself for not having done that before. However, one of the things I have not found in the documentation is some way of preparing output from R for convenient formatting into something like MS Word. An example: If you use summary(lm(....)) you get nice output. However, if you try to paste that output into the word processor, all the text elements are separated by blanks, and that is not optimal for the creation of a table (in the word processing sense). Is there an option to generate tab-separated output in R ? That would solve the problem. Tom +----------------------------------------------------------------+ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185 Fax : +47-5558-9879 | | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | +----------------------------------------------------------------+ ______________________________________________ R-help at 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
In Word use a fixed font such as Courier rather than a proportional font and it will look ok. On 2/9/06, Tom Backer Johnsen <backer at psych.uib.no> wrote:> I have just started looking at R, and are getting more and more irritated > at myself for not having done that before. > > However, one of the things I have not found in the documentation is some > way of preparing output from R for convenient formatting into something > like MS Word. An example: If you use summary(lm(....)) you get nice > output. However, if you try to paste that output into the word processor, > all the text elements are separated by blanks, and that is not optimal for > the creation of a table (in the word processing sense). > > Is there an option to generate tab-separated output in R ? That would solve > the problem. > > Tom > > +----------------------------------------------------------------+ > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > | Tel : +47-5558-9185 Fax : +47-5558-9879 | > | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | > +----------------------------------------------------------------+ > > ______________________________________________ > R-help at 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 >
Le 09.02.2006 15:41, Tom Backer Johnsen a ??crit :>I have just started looking at R, and are getting more and more irritated >at myself for not having done that before. > >However, one of the things I have not found in the documentation is some >way of preparing output from R for convenient formatting into something >like MS Word. An example: If you use summary(lm(....)) you get nice >output. However, if you try to paste that output into the word processor, >all the text elements are separated by blanks, and that is not optimal for >the creation of a table (in the word processing sense). > >Is there an option to generate tab-separated output in R ? That would solve >the problem. > >Tom > >Hi , One way could be to output in html format from R (with the R2HTML package) and then read back the html from your word processor Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques mixmod 1.7 is released : http://www-math.univ-fcomte.fr/mixmod/index.php +---------------------------------------------------------------+ | Romain FRANCOIS - http://francoisromain.free.fr | | Doctorant INRIA Futurs / EDF | +---------------------------------------------------------------+
Tom Backer Johnsen <backer at psych.uib.no> wrote: [...]> However, one of the things I have not found in the documentation is some > way of preparing output from R for convenient formatting into something > like MS Word.In case you're not talking about table-like output exclusively, reading ?Devices describes all the available kinds of graphical output. Most of these can then easily be included in MS Word. Cheers, -- Sebastian P. Luque
> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Romain Francois > Sent: Thursday, February 09, 2006 3:54 PM > To: Tom Backer Johnsen > > One way could be to output in html format from R (with the R2HTML > package) and then read back the html from your word processor > > RomainIf you go along the HTML path, the package xtable might be also your friend: library(xtable) mymat <- matrix(1:9, ncol=3) print.xtable(xtable(mymat), type="HTML") Hope this is useful for you, Roland +++++ This mail has been sent through the MPI for Demographic Rese...{{dropped}}
I have added several convenient methods for sending data directly from R to Microsoft Word (report() function) in the svViews package (SciViews bundle). However, I still have to upload it to CRAN. I do it right now. It should be available in a couple of days. Best, Philippe Grosjean Romain Francois wrote:> Le 09.02.2006 15:41, Tom Backer Johnsen a ??crit : > > >>I have just started looking at R, and are getting more and more irritated >>at myself for not having done that before. >> >>However, one of the things I have not found in the documentation is some >>way of preparing output from R for convenient formatting into something >>like MS Word. An example: If you use summary(lm(....)) you get nice >>output. However, if you try to paste that output into the word processor, >>all the text elements are separated by blanks, and that is not optimal for >>the creation of a table (in the word processing sense). >> >>Is there an option to generate tab-separated output in R ? That would solve >>the problem. >> >>Tom >> >> > > Hi , > > One way could be to output in html format from R (with the R2HTML > package) and then read back the html from your word processor > > Romain >
I agree that this is the best way. I often use Courier font with font size 10 that gives very good results. On Thu, 2006-02-09 at 09:47 -0500, Gabor Grothendieck wrote:> In Word use a fixed font such as Courier rather than a proportional > font and it will look ok. > > On 2/9/06, Tom Backer Johnsen <backer at psych.uib.no> wrote: > > I have just started looking at R, and are getting more and more irritated > > at myself for not having done that before. > > > > However, one of the things I have not found in the documentation is some > > way of preparing output from R for convenient formatting into something > > like MS Word. An example: If you use summary(lm(....)) you get nice > > output. However, if you try to paste that output into the word processor, > > all the text elements are separated by blanks, and that is not optimal for > > the creation of a table (in the word processing sense). > > > > Is there an option to generate tab-separated output in R ? That would solve > > the problem. > > > > Tom > > > > +----------------------------------------------------------------+ > > | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | > > | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | > > | Tel : +47-5558-9185 Fax : +47-5558-9879 | > > | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | > > +----------------------------------------------------------------+ > > > > ______________________________________________ > > R-help at 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 > > > > ______________________________________________ > R-help at 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 >
Tom Backer Johnsen wrote:> I have just started looking at R, and are getting more and more irritated > at myself for not having done that before. > > However, one of the things I have not found in the documentation is some > way of preparing output from R for convenient formatting into something > like MS Word.Well whatever you do, don't start looking at LaTeX, because that will get you even more irritated at yourself for not having done it before. LaTeX is to Word as R is to what? SPSS? I've still not seen a pretty piece of mathematics - or even text - in Word. Barry
Take a look at the facilities to write HTML output in library(R2HTML). If you write an HTML file, you can then easily copy and paste it into your Word document, or from MS Word you can use the Insert menu. i.e. library(R2HTML) x=ftable(Titanic, row.vars = 1:3) HTML(x,"Titanic.html") Then from MS Word use Insert-> File and select Titanic.html and see the results. I hope this helps Francisco>From: Tom Backer Johnsen <backer at psych.uib.no> >To: r-help at stat.math.ethz.ch >Subject: [R] Tranferring R results to word prosessors >Date: Thu, 09 Feb 2006 15:41:09 +0100 > >I have just started looking at R, and are getting more and more irritated >at myself for not having done that before. > >However, one of the things I have not found in the documentation is some >way of preparing output from R for convenient formatting into something >like MS Word. An example: If you use summary(lm(....)) you get nice >output. However, if you try to paste that output into the word processor, >all the text elements are separated by blanks, and that is not optimal for >the creation of a table (in the word processing sense). > >Is there an option to generate tab-separated output in R ? That would solve >the problem. > >Tom > >+----------------------------------------------------------------+ >| Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | >| University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | >| Tel : +47-5558-9185 Fax : +47-5558-9879 | >| Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | >+----------------------------------------------------------------+ > >______________________________________________ >R-help at 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
At 11:42 10.02.2006 -0300, CENDOYA, Maria Gabriela wrote:>X-UIDL: PE5!!DnS!!np3"!Sl2"! > >Hi Tom: > > May be I didn't understand your question but, what I do to cut >and paste results from say summary.lm, in a word processors without losing >the nice shape of the R Console, is to choose the same type of letter in >both,That works -- to some extent. But, that means that the formatting of the table is completely dependent on the number of spaces between the elements. It is essentially the same kind of formatting of tables I did on my first typewriter about 40 years ago. Any nontrivial change is troublesome, and you have to stick to fixed size fonts like Courier. Modern editors have moved far beyond that point. This is about generating a table in a text document from R type output. This type of table increases flexibility in respect to formatting.> I mean, in my R Gui preferences I use Courier New size 10, >then if I choose that type of letter in my word processors, I see the same >in both windows.Yes. Tom +----------------------------------------------------------------+ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185 Fax : +47-5558-9879 | | Email : backer at psych.uib.no URL : http://www.galton.uib.no/ | +----------------------------------------------------------------+
When transferring data frame output to word it's easy to use: write.table(df, file="clipboard",sep="\t") #df is your dataframe in this case Now you can go to Word en paste your table with tabs. Good luck Bart Joosen> On Thursday 09 February 2006 20:08, Patrick Burns wrote: >> One approach is to use LyX (http://www.lyx.org/). >> This is a lot like using Word or other word processors >> but it creates LaTeX. You probably won't need to >> know anything about TeX for a long time unless you >> are doing really weird things. >> >> Patrick Burns >> patrick at burns-stat.com >> +44 (0)20 8525 0696 >> http://www.burns-stat.com >> (home of S Poetry and "A Guide for the Unwilling S User") >> >> roger bos wrote: >> >Yeah, but I don't understand LaTeX at all. Can you point me to a good >> >beginners guide? >> > >> >Thanks, >> > >> >Roger >> > >> >On 2/9/06, Barry Rowlingson <B.Rowlingson at lancaster.ac.uk> wrote: >> >>Tom Backer Johnsen wrote: >> >>>I have just started looking at R, and are getting more and more >> >> >> >>irritated >> >> >> >>>at myself for not having done that before. >> >>> >> >>>However, one of the things I have not found in the documentation is >> >>>some >> >>>way of preparing output from R for convenient formatting into >> >>>something >> >>>like MS Word. >> >> >> >>Well whatever you do, don't start looking at LaTeX, because that will >> >>get you even more irritated at yourself for not having done it before. >> >> >> >>LaTeX is to Word as R is to what? SPSS? >> >> >> >>I've still not seen a pretty piece of mathematics - or even text - in >> >>Word. >> >> >> >>Barry