How to save an interactive plot produced by ggvis? - r

I have produced a plot using the ggvis package in R. The plot is interactive which can be changed by moving around the slider. However when I save it, it is just a picture of current status without sliders.
I have seen people posting these interactive plots on the website, so I think there should be a way to save it first. How can I do this?

From the Rstudio page for ggvis:
Note: If you’re viewing the HTML version of this document generated with knitr, the examples will have their interactive features disabled. You’ll need to run the code in R to see and use the interactive controls.
From this and the whole page I gather that sharing the interactive graphics can be done using Shiny Apps and/or R Markdown documents. To deploy either of those to people who do not have R installed you need to a) use Shiny Apps IO; or b) install Shiny Server, which has a free version with very basic administration capabilities, and a paid version for confidential information in corporate environment (which I'm only mentioning in case you are not allowed to share your data).
Either way, read through the Shiny Tutorial, the
R Markdown Tutorial, and the combination.

Related

R shiny able to display graphs once but not able to display the next time when app loaded

I have an R shiny application deployed in web..It somestimes displays the graphs in the shiny app but when i run it again using the same setting eveything it is not able to display..There is no bug in the code because once it is able to display..I have also used different browsers but nothing worked..Any suggestions are welcome..I used ggplot2 for displaying graphs..But the same code worked in different linux server and able to produce the graphs persistenly..is there any packages or anything i could do it to server?Thanks

R : GUIs fast to launch (alternatives to shiny ?)

I am trying to make some GUI for my CRAN package
some f function that locally launches a popup with a few params rendering a few outputs, like launching locally a simple shiny app.
the popup permits to select the parameters easily and then a "validate" button triggers the return of fwith the selected parameters, like shiny with stopApp
I have already done that with shiny but i think the result is a bit unsatisfying because shiny apps are slow to launch and stop (if there is an object to serialize i guess).
I have seen that some packages, like vdiffr, seem to answer this problem by making a list of the objects to change, thus they only launch shiny once to change everything with some selecter. If possible I'd like to avoid this solution.
So the question is : is there some kind of GUI framework more convenient than Shiny for this (only local, fast launch and fast return) ? Or some fine way to do that, that is light enough (I don't want to make my package to be extraordinary heavy for a small popup) ?
Here are GUI facilities that come with R (no packages needed):
(1) For sufficiently simple applications select.list, menu, readline, file.choose and choose.dir can be used and will present with a text or graphical user interface depending on what environment the user has. These all come with R and launch very quickly and are easy to program. See the help pages of those commands and try:
select.list(c("oranges", "apples", "pears"))
menu(c("oranges", "apples", "pears"))
readline("Enter name of fruit: ")
choose.dir()
file.choose()
(2) A possibility which is capable of user interfaces as sophisticated as shiny is the tcltk package. This comes with R so it does not need to be installed. It only needs to be loaded using a library statement. (If a user builds R from source then it is possible to build it without tcltk capability but in 99% of all cases tcltk will be present).
There are a few short examples of R source code employing tcltk here: https://www.stat.berkeley.edu/~s133/Gui-a.html, quite a few more examples at James Wettenhall's site and one can run the Rcmdr R package to see an example of a sophisticated tcltk user interface although running Rcmdr will take longer to load than a simple application due to its large size.
Because tcltk is a part of R itself it does not have a CRAN page but for additional packages that use tcltk look at the reverse dependencies of the tcltk2 package at the bottom of its CRAN page since any package that depends on it must also use tcltk.
That really depends on your coding knowledge. My first approach, however, would be to try to improve your shiny app. For that you can use the profvis package to check why exactly your shiny app is slow. Should you decide to stay with Shiny, there a lot of ways on how to reduce the starting time of Shiny. However, if you should come to the conclusion, that you really want to throw shiny overboard, then you should consider using JavaScript.
Either you write your complete app in pure JavaScript
Or you can use JavaScript within Shiny (e.g. r2d3)
Of course there are other ways as #Pork Chop mentioned of using rmarkdown or normal markdown.

Interactive R Notebooks/Dashboards for Non-R Users

Not sure this is the right place for this kind of question, but I am looking for ideas on how to share some R Markdown Notebooks with non-R users, but that still have some dynamic functionality in them. For example, I can create a notebook with html-widgets to adjust time windows, choose different data points, etc. I compile this in R Studio and it looks great on my machine. But sharing the .nb.html file with co-workers, they don't get the same level of interactivity, which is expected.
Is there a way to share these files or similar R files with non-R users? Additionally, I don't have access to a personal/company website where I could host these notebooks.
you could for example use :
DT package to give your Rmd output filter- able html data frames .
you can also use plotly() to have interactiv plots [easy to do for ggplot2 users using ggplotly() ]
further check out :
flexdashboards https://rmarkdown.rstudio.com/flexdashboard/
sematic dashboards. https://cran.r-project.org/web/packages/semantic.dashboard/semantic.dashboard.pdf
both are solutions for more dynamic Rmarkdown reports, but not as demanding to programm as full blown shiny apps.

Can we use RStudio's viewer within a shiny app?

Problem: ploting images is usually long in R (user-side), even when using raster.
Possible trail: With images as objects of class magick-image, one can use RStudio's viewer as proposed/implemented in the magick's package vignette.
There is an open issue on magick's github repos dedicated to this particular magick+ shiny combination and detailing the rationale.
What I have found: Rstudio's support indicates how to display a shiny app within the viewer but I'm looking for the opposite: display an efficient viewer within a shiny app.
Question: is there a generic way to integrate RStudio's viewer (or equivalent) within a shiny app?
(By the way) question: can we retrieve clicked coordinates and other events from the viewer (or equivalent)?

R Plot Auto-View

I'm trying to figure a way to automatically open the pdf-output of an R script after i run it. My goal is to integrate that into Sublime Text (under osx) to make something like an automatic viewer for my generated plots.
Any idea is welcome (obviously if there exists a plugin that already acts as a viewer for R, much better)

Resources