Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a landscape table in a word document

Tags:

r

reporters

I am using ReporteRs package in R to create a report. I have a table which has 13 columns and I would like it to go in a landscape orientation. Otherwise some columns will be cut down from the table. I am wondering whether it is possible to specify this in ReporteRs for a specific FlexTable object? All the other tables and texts come in portrait format. My apologies for not giving a reproducible example. Thank you in advance.

like image 716
JeanVuda Avatar asked Jan 31 '15 18:01

JeanVuda


1 Answers

You can do it with addSection:

library(ReporteRs)
doc = docx()
doc = addSection( doc, landscape = T ) 
doc = addFlexTable( doc, FlexTable( mtcars) )
doc = addSection( doc, landscape = F ) 
writeDoc( doc, "test.docx")

Another solution would be to create an empty Word document with landscape orientation and then to use it as a template:

library(ReporteRs)
doc = docx(template = "your_landscape_doc.docx")
doc = addFlexTable( doc, FlexTable( mtcars) )
writeDoc( doc, "test.docx")
like image 174
David Gohel Avatar answered Nov 03 '22 22:11

David Gohel