# NOT RUN {
# Create a new document
doc = docx( title = "title" )
# Add "Hello World" into the document doc
doc <- addParagraph(doc, "Hello Word!", "Normal");
# Add into the document : "My tailor is rich" and "Cats and Dogs"
# format some of the pieces of text
pot1 = pot("My tailor", textProperties(color="red") ) + " is " + pot("rich", textProperties(font.weight="bold") )
my.pars = set_of_paragraphs( pot1 )
pot2 = pot("Cats", textProperties(color="red") ) + " and " + pot("Dogs", textProperties(color="blue") )
my.pars = set_of_paragraphs( pot1, pot2 )
# used style is "BulletList" so that paragraphs will be preceded by bullet points
# ("BulletList" is an existing style in the defaut template docx of the package)
doc <- addParagraph(doc, my.pars, "BulletList");
# Write the object in file "~/document.docx"
writeDoc( doc, "~/document.docx" )
# }
Run the code above in your browser using DataLab