How to export an interactive image created in R in PDF? - r

I would like to know a way to create the interactive image in R and convert it to PDF so that from the PDF I can manipulate it, that is, it remains interactive. I created an interactive image in R but when I save it it becomes static, I tried to make it in RMarkdown but it only allows me to convert it to html. Help me please.

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)

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").

Is it possible to use Rtable (FlexTable) to generate a pdf table in RMarkdown

I'm creating some RMarkdown reports and want to be able to extensively format a table. I've tried working with kable and pander but they don't give me enough functionality (for example to use colors for rows).
I ran across the Rtable package (that goes along with the FlexTable object of the Reporters package) which allows significant customization. The only problem is that I can so far only get my table to show up when I knit to html, when I knit to pdf (what I need) I just get an unformatted list of text instead of my table.
here's what my code looks like (summaryterms is a dataframe)
setZebraStyle(FlexTable(summaryterms[c(5,1:3,9:11,14)]),odd = "#DDDDDD", even = "#FFFFFF" )
Is there anyway to use the FlexTable object with a pdf report?
Thank you so much for the help
Also, I'm open to any and all other solutions to format tables in rmarkdown, I'm not married to using flextable.

Is there a way to export rMaps output to image?

I'm starting to work with rMaps (following this example), and it's a great package. I'd like to include the results in a document, either by exporting the result to a .jpeg, .png or other graphical format, or by rendering the output directly into a LaTeX document (using sweave or knitr). However, after searching a lot, I've found no way to do it.
So, the question is: Is there a (preferibly simple) way to export rMaps result (ichoropleth, crosslet and/or Leaflet) directly to an image file (or set of files)?

Easy way to copy paste base graph from R Studio into word document

I need to copy paste R graphs into MS Word.
rando<-rnorm(1:100)
plot(rando)
when I copy the .png graph from R Studio into Word I get a negative space version of the graph:
Is there a cleaner/easier way to do this? I would be happy to use pdf or something else to present the graph.
As #Roland suggested:
Export -> Copy Plot to Clipboard (window with plot will pop-out) -> Metafile -> Copy Plot -> Paste to MSWord.
This seems a lot of clicks to me, rather as #user2633645 suggested save all plots as png then insert them in MSWord in one go.
?png
rando<-rnorm(1:100)
png(filename = "rando.png")
plot(rando)
dev.off()
You can use the devEMF package. It is repeatable, easy to use, and converts very nicely to pdf if needed.
(wow is this an old question, but I guess it's still an issue. I'm on RStudio v1.3.1073)
I came across 3 options:
Cross posting from https://github.com/rstudio/rstudio/issues/5103#issuecomment-679021780: "I've found two simple workarounds: Paste Special and choose TIFF, or (my preference) drag the image from the zoom window and drop in PowerPoint"
Snipping tool
You can specify the dimensions like in the RStudio plot export
windows(800,600) ## Opens graphic window. ctrl c/v works here.
plot(rando)
If you are doing this copy-plot-to-Word often or for several plots, consider creating an .Rmd file with your code, call knitr on that file, and use system("pandoc to convert your knitted .md file to Word.

Resources