# docx example ---------
doc.filename = "ex_codeblock.docx"
options( "ReporteRs-fontsize" = 10 )
doc <- docx( )
doc <- addCodeBlock( doc, text = "ls -a\nwhich -a ls" )
writeDoc( doc, file = doc.filename )
# bsdoc example --------
doc.filename = "ex_codeblock/example.html"
options( "ReporteRs-fontsize" = 11 )
doc = bsdoc( )
doc <- addCodeBlock( doc, text = "ls -a\nwhich -a ls" )
writeDoc( doc, file = doc.filename )
# docx example ---------
doc.filename = "ex_codeblock.pptx"
options( "ReporteRs-fontsize" = 24 )
doc = pptx( title = "title" )
# add a slide with layout "Title and Content"
doc = addSlide( doc, slide.layout = "Title and Content" )
doc = addTitle( doc, "Title example 1" )
doc <- addCodeBlock( doc, text = "ls -a\nwhich -a ls" )
writeDoc( doc, file = doc.filename )
Run the code above in your browser using DataLab