Rendering a shiny plot in vectorized graphics (.svg) instead of .png - r

ggplot2 is able to export plots in vector formats like SVG. Plots rendered in Shiny with plotOutput() are rendered in PNG format. Is it possible to render Shiny plots in SVG format?

It is possible to output ggplots in a Shiny app as vectors thanks to the package ggiraph, by David Gohel. The package also supports basic interactivity to ggplot2 plots, like tooltips, highlighting, and more.

Related

Is there a way to recover a ggplot2 image from a Plotly image?

I have some code that generates a plotly image in R. Previously I included this plot in a presentation using Rstudio/ioslides. The people I am collaborating with want a version in powerpoint. I am trying to use the ReporterRs package in order to create an re-producible shell powerpoint presentation with all of my plots. However ReporterRs only accepts lattice, ggplot2, and base images. Since there is a way to convert ggplot2 objects to plotly images I was hoping there was a way to go backwards. However I am stuck. I have been unable to "downgrade" my plotly plots to ggplot2. Does anyone know if there is a way to do this?
(I know I can just copy and paste them over but I would like to develop a workflow where I can create easily reproducible and replaceable plots so that I don't have to do very much work if I change the data)

How to download shiny graph in PDF Formart

I am new to R programming. I have developed a shiny dashboard application for different visualization purposes where I am plotting various graphs with the help of renderDataTable, renderPlot, renderRpivotTable, renderImage renderInfoBox.
But I am unable to figure out what is the best way to download these graphs/charts/table/infobox in PDF format.
So for I am rendering Rmarkdown within downloadHandler to achieve this requirement. But It is not working for every plot such renderInfoBox,renderDataTable. I will highly appreciate any inputs on this.

How can I plot a zoomable plot in knitr

I an using knitr for automatic html reports. I would like to be able to plot simple scatter plots (like time serie plots) but interactive ones, that would be zoomable.
Ideally I could then use it in a knitr html document.
I had a look at rgl but it seems overkill for my simple needs. What should I use ?
Have a look into ggvis and/or rCharts.
Especcaly have a look at this example page of stock-data with rCharts:
http://timelyportfolio.github.io/rCharts_time_series/history.html
"rCharts 2013" might be interessting for you.
And this is an example of Markdown with knitr and rCharts:
http://rstudio-pubs-static.s3.amazonaws.com/9331_9b5778029d1e46d0b3afcf1d861d7e70.html

How to download rCharts plots in shiny with downloadHandler

In shiny apps ggplot2 graphs can easily be downloaded based on the downloadHandler function. Is it possible to download the javascript visualisations that are produced by means of rCharts in a similar way? If yes, what is the best approach?
If you use the HighCharts capability of rCharts then you can use it's exporter feature which has an download capability as demonstrated here (source).
If not, you're left with DOM introspection like I ended up using here. That has no R behind it, but it shows how to find the SVG in the DOM and make it so the graphic is exportable in a couple different ways.

Non-interactive GoogleVis charts

Is it possible for googleVis Package from R to generate Images as oppose to interactive charts? To create a GoogleVis Chart in R:
library(googleVis)
M <- gvisMotionChart(Fruits, "Fruit", "Year")
plot(M)
This initiates a browser and then it will plot an interative chart. Is there a way such that I can create a non-interactive image and plot it in R
What I have done is a complete hack, but it works. I view the HTML for the googleVis object generated and extract the svg. I save the svg as a file and open it in an image editor that can open and convert svg files.
There's no real need to use googleVis for this. If you create your plot in ggplot2, the ggthemes add-on package has theme_gdocs(), and associated colour palettes that will let you style your chart exactly like a Google Chart.
It looks like the only way to do this is to make the interactive plot, and take a screenshot. The object returned by googleVis is a Flash application embedded in html, I think you probably cannot expect it to give a static plot!
Some hacks I found that could potentially be able to convert gvis charts to images:
http://html2canvas.hertzen.com/
https://gist.github.com/battlehorse/1333906

Resources