ReporteRs (version 0.8.6)

addRScript: Add R script into a document object

Description

Add R script into a document object

Usage

addRScript(doc, rscript, file, text, ...)
"addRScript"(doc, rscript, file, text, bookmark, par.properties = parProperties(), ...)
"addRScript"(doc, rscript, file, text, append = FALSE, ...)
"addRScript"(doc, rscript, file, text, ...)

Arguments

doc
document object
rscript
an object of class RScript. Not used if file or text is provided.
file
R script file. Not used if text or rscript is provided.
text
character vector. The text to parse. Not used if file or rscript is provided.
...
further arguments passed to other methods
bookmark
a character value ; id of the Word bookmark to replace by the script. optional. See bookmark.
par.properties
paragraph formatting properties of the paragraphs that contain rscript. An object of class parProperties
append
boolean default to FALSE. If TRUE, paragraphs will be appened in the current shape instead of beeing sent into a new shape. Paragraphs can only be appended on shape containing paragraphs (i.e. you can not add paragraphs after a FlexTable).

Value

a document object

Details

You have to one of the following argument: file or text or rscript.

See Also

bsdoc, docx, pptx

Examples

Run this code

# docx example -----------
doc.filename = "ex_rscript.docx"

options( "ReporteRs-fontsize" = 10 )
doc <- docx( )
doc = addRScript(doc, text = "x = rnorm(100)
plot(density( x ) )" )

writeDoc( doc, file = doc.filename )

# pptx example -----------
doc.filename = "ex_rscript.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 = addRScript(doc, text = "x = rnorm(100)
plot(density( x ) )" )

writeDoc( doc, file = doc.filename )

# bsdoc example -----------
doc.filename = "ex_rscript/example.html"

options( "ReporteRs-fontsize" = 11 )
doc = bsdoc( )
doc = addRScript(doc, text = "x = rnorm(100)
plot(density( x ) )" )

writeDoc( doc, file = doc.filename )

Run the code above in your browser using DataLab