[R] [External] Best practice for copying statistical output from RStudio to Word using Times New Roman

Richard M. Heiberger rmh @end|ng |rom temp|e@edu
Wed Nov 26 23:16:56 CET 2025


## I would suggest using Hmisc:latex


library(Hmisc)
HH::latexSetOptions()

x <- matrix(1:6, nrow=2, dimnames=list(c('a','b'),c('c','d','this that')))
x

w <- latex(x, file='~/tmp/my.tex')
w$file
print.default(w)

w          ## constructs and displays a pdf file with a temporary name

HH::pdf.latex(w, file="~/tmp/my.pdf") ## constructs a pdf file with specified name
system("open  ~/tmp/my.pdf") ## display file

## construct .docx file
## assuming pandoc is installed at /usr/local/bin/pandoc
system("/usr/local/bin/pandoc -o ~/tmp/my.docx ~/tmp/my.tex")

## Now you can open ~/tmp/my.docx in MS Word, and you have a nice table in a default font.
system("open  ~/tmp/my.docx")
## Change the font from the MS Word default font to Times New Roman (or anything else).


## latex() and related functions allow quite complex tables to be constructed in latex.
## Some are more complex than pandoc is able to translate cleanly into MS Word.
?Hmisc::latex



> On Nov 22, 2025, at 10:11, tgs77m--- via R-help <r-help using r-project.org> wrote:
>
> Thanks all!
>
> This is an  elegant solution!
>
>
>
> TS
>
>
>
> From: John Kane <jrkrideau using gmail.com>
> Sent: Friday, November 21, 2025 7:58 AM
> To: Greg Snow <538280 using gmail.com>
> Cc: tgs77m using yahoo.com; r-help using r-project.org
> Subject: Re: [R] Best practice for copying statistical output from RStudio to Word using Times New Roman
>
>
>
> I second Greg's recommendation.  Creating a Quarto or Rmarkdown document and doing all text production and analysis in it  is much more productive. It definitely makes changes and editing much easier and  much less error prone.
>
>
>
> My personal preference is Quarto but either is several orders of magnitude better than cut and paste.
>
>
>
> On Fri, 21 Nov 2025 at 10:40, Greg Snow <538280 using gmail.com <mailto:538280 using gmail.com> > wrote:
>
> Here are a couple of things that I have found useful for when you need
> the final results in MS Word and you want nice formatting.
>
> Use a quarto or Rmarkdown document and have knitr/pandoc create the
> word document instead of copy/paste.  The pander package does some
> nice formatting for many of the statistical routines that pandoc
> converts into tables.
>
> If you need to copy and paste, first copy and paste to MS Excel (and
> for tables, you can use write.table with file="clipboard" and
> sep="\t", then just paste in Excel).  Then maybe make some adjustments
> in Excel, then copy from Excel to Word, this will keep things as a
> table in word, so changing the font will not mess with the alignment.
>
> The broom package takes output from lm models and puts them into data
> frames (tibbles) that can be exported to Excel>Word instead of relying
> on fixed width fonts and spaces for formatting.
>
>
> On Fri, Nov 21, 2025 at 8:27 AM tgs77m--- via R-help
> <r-help using r-project.org <mailto:r-help using r-project.org> > wrote:
>>
>> The root cause is that RStudio’s output console is hardwired to use monospaced fonts like Consolas, Courier, or Monaco, which preserve column alignment. Times New Roman (TTR), being proportional, breaks that alignment when pasted into Word unless you manually reformat.
>>
>>
>>
>>
>>
>> From: CALUM POLWART <polc1410 using gmail.com <mailto:polc1410 using gmail.com> >
>> Sent: Friday, November 21, 2025 5:02 AM
>> To: Viechtbauer, Wolfgang (NP) <wolfgang.viechtbauer using maastrichtuniversity.nl<mailto:wolfgang.viechtbauer using maastrichtuniversity.nl> >
>> Cc: Thomas Subia <tgs77m using yahoo.com <mailto:tgs77m using yahoo.com> >; r-help using r-project.org <mailto:r-help using r-project.org>
>> Subject: Re: [R] Best practice for copying statistical output from RStudio to Word using Times New Roman
>>
>>
>>
>> As Wolfgang says.
>>
>>
>>
>> Ctrl-Shift-V and plain text.
>>
>>
>>
>> That said... I bet some of it looks awful as it's probably spaced for a fixed width font.
>>
>>
>>
>> On Fri, 21 Nov 2025, 10:28 Viechtbauer, Wolfgang (NP) via R-help, <r-help using r-project.org <mailto:r-help using r-project.org>  <mailto:r-help using r-project.org <mailto:r-help using r-project.org> > > wrote:
>>
>> Dear Thomas,
>>
>> Just paste without formatting. Then the pasted text will be in the active font of the Word document.
>>
>> Best,
>> Wolfgang
>>
>>> -----Original Message-----
>>> From: R-help <r-help-bounces using r-project.org <mailto:r-help-bounces using r-project.org>  <mailto:r-help-bounces using r-project.org <mailto:r-help-bounces using r-project.org> > > On Behalf Of tgs77m--- via R-help
>>> Sent: Friday, November 21, 2025 07:51
>>> To: r-help using r-project.org <mailto:r-help using r-project.org>  <mailto:r-help using r-project.org <mailto:r-help using r-project.org> >
>>> Subject: [R] Best practice for copying statistical output from RStudio to Word
>>> using Times New Roman
>>>
>>> Colleagues
>>>
>>> I am writing an article using Microsoft Word for a journal that requires
>>> Times New Roman for all text (including tables and statistical outputs).
>>> However, copying console output from RStudio (e.g., summary(lm())) into Word
>>> retains the RStudio monospace font, and Word does not automatically convert
>>> it to Times New Roman. Manually restyling each pasted block is
>>> time-consuming and error-prone.
>>>
>>> s there a recommended workflow for preserving proper alignment while
>>> achieving Times New Roman text formatting when transferring statistical
>>> results from RStudio into Word?
>>>
>>> System:
>>> Windows 11
>>> R 4.5.1
>>> RStudio 2024.12.0+
>>>
>>> Thanks for any guidance or best practices.
>>>
>>> Best regards,
>>> Thomas Subia
>>
>> ______________________________________________
>> R-help using r-project.org <mailto:R-help using r-project.org>  <mailto:R-help using r-project.org <mailto:R-help using r-project.org> > mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide https://www.r-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org <mailto:R-help using r-project.org>  mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide https://www.r-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> 538280 using gmail.com <mailto:538280 using gmail.com>
>
> ______________________________________________
> R-help using r-project.org <mailto:R-help using r-project.org>  mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide https://www.r-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>
> --
>
> John Kane
> Kingston ON Canada
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide https://www.r-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list