forest forest - 1 year ago 137
R Question

Change line spacing in docx using ReporteRs in R

I'm creating a word document using the ReporteRs package in R, and I want to change the spacing of a paragraph from single spaced to 1.5 spaced.

I guess I could enter each line as a new paragraph and put a buffer at the start of each of those "paragraphs" but I'm looking for a cleaner way.

I'm open to using another package if it would work.

Answer Source

You could define a paragraph with line space 1.5 (with name myparag) in an empty Word document and reuse it as a template (filename: template.docx).

doc <- docx() 
styles( doc ) # check value `myparag` is in the available paragraph styles
doc <- addParagraph(doc, "Blah blah blah", stylename = "myparag")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download