Closed rpruim closed 8 years ago
require( ggplot2 ) doc = docx( title = 'My document' ) doc = addTitle( doc , 'First 5 lines of iris', level = 1) doc = addFlexTable( doc , vanilla.table(iris[1:5, ]), layout.properties= get.light.tableProperties()) doc = addTitle( doc , 'ggplot2 example', level = 1) myggplot = qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width ) doc = addPlot( doc = doc , fun = print, x = myggplot ) doc = addTitle( doc , 'Text example', level = 1) doc = addParagraph( doc, 'My tailor is rich.', stylename = 'Normal' ) writeDoc( doc, 'files/gettingstarted/my_first_doc.docx' )
becomes
require(magrittr) require( ggplot2 ) myggplot = qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width ) doc <- docx(title = 'My document') %>% addTitle('First 5 lines of iris', level = 1) %>% addFlexTable(vanilla.table(iris[1:5, ]), layout.properties= get.light.tableProperties()) %>% addTitle( doc , 'ggplot2 example', level = 1) %>% addPlot(fun = print, x = myggplot) %>% addTitle('Text example', level = 1) %>% addParagraph('My tailor is rich.', stylename = 'Normal') doc %>% writeDoc('files/gettingstarted/my_first_doc.docx')
thanks,
in the next doc update, I will make a mention to magrittr.
magrittr
becomes