is_sunos <- tolower(Sys.info()[["sysname"]]) == "sunos"
options( "ReporteRs-fontsize" = 11 )
# plot example for docx -----
doc = docx( )
doc = addPlot( doc, fun = function() barplot( 1:6, col = 2:7),
vector.graphic = TRUE, width = 5, height = 7,
par.properties = parProperties(text.align = "center")
)
writeDoc( doc, file = "ex_plot.docx" )
# plot example for pptx -----
doc = pptx( )
doc = addSlide( doc, slide.layout = "Title and Content" )
doc = addPlot( doc, fun = function() barplot( 1:6, col = 2:7),
vector.graphic = TRUE, width = 5, height = 4 )
if( !is_sunos ){
doc = addPlot( doc,
fun = function() barplot( 1:6, col = 2:7),
vector.graphic = FALSE,
offx = 7, offy = 0,
width = 3, height = 2
)
}
writeDoc( doc, file = "ex_plot.pptx" )
# plot example for bsdoc -----
doc = bsdoc( )
doc = addPlot( doc, fun = function() barplot( 1:6, col = 2:7),
vector.graphic = TRUE, width = 5, height = 7,
par.properties = parProperties(text.align = "left")
)
writeDoc( doc, file = "ex_plot/example.html" )
## Not run:
# if(require(ggiraph)){
# gg_p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width,
# tooltip = Species)) +
# geom_point_interactive(size = 3)
#
# doc <- bsdoc()
# download.file("https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js",
# destfile = "d3.min.js")
# doc <- addJavascript(doc = doc, file = "d3.min.js" )
# unlink("d3.min.js")
# doc <- addPlot(doc, fun = function() print(gg_p), ggiraph = TRUE)
#
# writeDoc(doc, "ggiraph/index.html")
# }
# ## End(Not run)
Run the code above in your browser using DataLab