embedding a R animated 3D plot in PowerPoint - r

The rgl R package allows to plot interactive 3D figures and to save these figures in a html document (with the writeWebGL() function).
I would like to put such an interactive 3D figure in a PowerPoint presentation. Is it possible ?
EDIT: After studying Dieter Menne's answer with the help of Google, my conclusions are the following ones:
Currently Luke Tierney's method to convert a 3D graphic to an U3D file and/or an Asymptote file only works for graphics created with the misc3d package, not the rgl package.
The export of 3D rgl graphics to VRML/X3D files has been announced as a future plan. Perhaps this would allow to embed a 3D rgl graphic into a Powerpoint and/or LaTeX presentation.
EDIT : related discussion

It is possible if you transfer the Powerpoint presentation (or, even more R-ish, use beamer/latex), and embed the 3D-plot as described in Luke Tierney's article
http://homepage.stat.uiowa.edu/~luke/R/misc3d/misc3d-pdf/misc3d-pdf.pdf

If you put this in to an HTML document, you can probably use the IWebBrowser2 object to open the HTML inside a Slide. I am not sure how a 3d graphic would render, and I'mnot familiar with R or would not be able to offer any further advice, but you might start by trying to simply create a WebBrowser object inside your slide, and then tell it to Navigate to the HTML file.
Sub InsertHTMLFrame()
Dim sld as Slide
Dim shp as Shape
Dim wb as Object
Set sld = ActivePresentation.Slides(1) '## Modify as needed
'## Create the shape container, you will need to modify the L/T/W/H to fit your document
Set shp = sld.Shapes.AddOLEObject(100, 200, 200, 150, _
"Shell.Explorer.2")
shp.Name = "3dgraphic"
Set wb = shp.OLEFormat.Object
wb.Navigate "C:\Users\you\Desktop\exported3dgraphic.html"
End Sub
Controlling this flow during SlideShow mode may be a little trickier, but it's doable, provided the graphic renders properly through IE like this.
How to Install This Macro
Open your PowerPoint Presentation, and click Alt+F11 to bring up the Visual Basic project.
Right-click the project in the left pane, and Insert Module:
Paste the code from my answer in to this module.
In the line that says wb.Navigate "C:\..." modify this to the correct file path for your HTML file. This can be on your computer or in a shared network folder, etc.
The browser should be able to display HTML pages when in SlideShow mode, but will not render them in the normal or preview mode.

Related

R officer: Is it possible to print slide as image (jpg, png or other formats)

I have a set of files all with 1 slide created with a custom template created with R officer package
Would like to print these individual slides as jpg or png. Current workflow is to print individual pptx files using the inbuilt print function and converting to image outside of R. The process to convert to image using office "Save As" function or a script is cumbersome.
Is there a plan to add this feature?
The package {doconv} can help you.
See https://cran.r-project.org/web/packages/doconv/readme/README.html
Function to_miniature create an image with your slides. (you will need LibreOffice).
pptx_file <- system.file(package = "doconv", "doc-examples/example.pptx")
to_miniature(pptx_file, width = 1000)

Inserting images in R markdown using a path variable

I am new to R and Rmd and trying to generate a report using Rmd. This report has several images inserted along with the text. I am able to insert an image by hardcoding the path of the image. I have no problems with that but I need the path as a variable because it varies with the project. Can anyone help me with the syntax for calling a variable within a path to the image?
![Relatedness check](/data/array_processing/in_progress/Project123/files/data/plots/Project123.ibd.png)
"Project123" changes based on the project. Is there a way I can declare this variable and call it to define the path?
Help please.
Images can use online R code for dynamic paths and/or alt text. (Early adopters of rmarkdown often tried this method as the default method of including R plots in the reports, using png(filepath...); plot(...); dev.off() followed by what I recommend you use.)
This will allow you to do what you need:
![something meaningful](`r filepath`)
as raw markdown (and not inside a traditional code chunk).
If you aren't familiar with inline code blocks, then know that you can put just about anything in an inline code block. This is handy for including dynamic content in a paragraph of text, for example "the variance of the sample is \r var(sample(99))``". (Often it is just a pre-created variable, if numeric it is often rounded or formated to control the display of significant figures.)

How to add an interactive heatmap to a PDF?

I have created a heatmap in R and heatmaply. I need to add this heatmap to a paper I am publishing. The heatmap is very big and heatmaply's zoom is very useful. Is it possible to add this heatmap - it becomes a .html file when saved - to a PDF?
Is there any method to add an interactive heatmap another than a hyperlink?
The short answer is - no. Adding interactive graphics (like heatmaply) to a PDF file is not possible. My best advice is to go for something that supports HTML.
You can, however, add a static image to a PDF file by outputting the heatmap from heatmaply by following the documentation: https://cran.r-project.org/web/packages/heatmaply/heatmaply.pdf (search for "static").

How to save or copy in the clipboard a graph made with Statet/R/Eclipse?

My setup: Eclipse, R and Statet
I am using R from inside Eclipse using Statet.
I have made a graph (this is the plot of a time series, in case this is relevant information).
I now wish to save this graph as a JPG image (or BMP, or the like ...), or to copy this image in the clipboard. I need my graph in a PowerPoint presentation.
Does anyone know how to do that?
Thank you
jpeg('foo.png') more help is available by typing ?jpeg at the statet prompt. You may also be able to write to the clipboard, using a destination of clipboard instead of the filename, depending on your platform -- see ?connections for further details.

Extracting path data from an SVG map to use in RaphaelJs

I'm trying to build an an interactive map using RaphaelJS (e.g. http://raphaeljs.com/australia.html). Please check the source. It requires map path data to input. There is no clear explanation anywhere about how to obtain this information, other than the fact that illustrator or inkscape are capable of doing it.
I'm looking to obtain "States" path data from this India map: http://en.wikipedia.org/wiki/File:India-locator-map-blank.svg
well, this one is easy. SVG is just a simple XML file. So you don't have to "extract" anything via Illustrator.
Just open the SVG in any text editor and it's all there! (the path data string you can use with RaphaelJS path-function is held in the d-attribute of the path nodes).
Watch our for copyright issues when using SVG files of others ;)
Skunks
You could also use a converter like Ready.Set.Raphael to extract the paths for you and create the javascript output. It's a real time saver!
For older SVG files the path data will need to be optimized for RaphaelJS. Open the file in Inkspace and save as Optimized AVG. If you have an AVG file that opens as a blank image in Adobe Illustrator, edit the file with a text editor and set the first two values of the viewBox to 0,0. Both steps may be required when working with map AVG files from Wikipedia.

Resources