I have to use htmlwidgets related packages(plotly and dygraphs) to generate plots which I can then either:
1. save as .html file and link them through an iframe.
2. use in a shiny app.
I would prefer creating my own UI instead of using Shiny, but:
If I don't use Shiny, every time I regenerate the plot(on some kind of user-interaction), the html file created by plotly/dygraphs (which is more than 1MB) needs to be transferred to the client. This might create a bottleneck.
Thus I would like to know if using Shiny would decrease the amount of data that needsto be transferred to client when re-rendering the plot on user-interaction.
If you are looking to create you're own UI, but still want R on the 'back-end', you should have a look at the openCPU project, which always you to define REST APIs backed by R functions that can be called from any web framework.
Related
Is it possible to publish an RMarkdown file to Rpubs that takes input and gives out put from the Rpubs site? I want to create a simple calculator related to my job that takes a few inputs and gives an output and, if possible, publish to Rpubs for people to view and use.
SHINY: I know this is what shiny is for, creating interactive apps, but I dont know it very well or how to implement an app I create for multiple people to use, or how to imbed the link to the app, and so on. Just trying to see if this is possible in things I already know how to use
RPubs is for HTML documents that don't require R calculations on the backend. In some instances, there can be some degree of interactivity e.g., brushing and linking plots, filtering data and having the filter propagate to a plot. These happen through the crosstalk package. However, it sounds like you need a shiny app that can take inputs and have R do some calculation of those on the back end. You could host your app on shinyapps.io
It's also possible, depending on how complicated the calculations are, that the entire app could be written in native javascript, which wouldn't require a server-side computation, so could be hosted on any website.
I am not sure if I can show any reproducible example here, however let me narrate the issue I am facing with my Shiny app.
I have a Shiny app, which is basically data driven. All my required data is saved in an RData file which is placed in WWW folder. When user put my Shiny app's address (which is hosted on Amazon AWS) i.e. when my Shiny app starts, that RData file is loaded onto R, and then subsequent calculation starts.
The issue is that, my RData file is of quite huge size ~50MB. So R takes quite long time to load that onto memory. From User's perspective, he/she is not sure what is happening behind the screen, that makes some of them leave my App.
So I was thinking if I can put some progress bar to show User something is happening, as that Progress bar would be displayed only during the time when R is loading my RData file. I am aware of various Progress bar schemes available for Shiny, however as far as I know they are to display progress only during calculation (e.g. simulation) not during loading something.
Any idea if it is possible to put some Progress bar during loading RData, package etc?
Thanks for any pointer.
maybe a bit late but I share what I used, should it be useful for someone else.
Take a look at the shinycssloaders package (https://github.com/andrewsali/shinycssloaders).
By adding a simple function withSpinner and set a few parameters, you'll be able to set loader animations to Shiny apps. Furthermore you can select different spinners by looking at this link https://projects.lukehaas.me/css-loaders/.
I used it when I made this app: https://abenedetti.shinyapps.io/bioNPS/
Look at the Species Choropleth map section.
Edit:
Maybe this article and this app could help. Did you had a look at them?
Lately I have been making several very similar Shiny apps for different clients and hosting them on shinyapps.io.
Each app has a different title, different data, some differences in branding etc. but otherwise the code is very similar.
I'm having trouble maintaining these apps. When find and fix a bug I currently have to go through 5 different apps and make the change each time.
Does anyone have good suggestions on how to handle this? Git branches? I know the best solution would be to have one app and upload different data, but that's not possible unfortunately.
I'd like to keep using shinyapps.io, but I'm open to hosting the apps somewhere else if it makes my workflow better.
As I wrote in the comment shinyModules() will help you: https://shiny.rstudio.com/articles/modules.html
Shiny modules are to shiny functions, like ordinary functions are to repeating code.
Or to put it differently:
Repeating code --> function
repeating shiny function --> shiny module
As the documentation is a bit complicated here and there, i wrote a simplified example here:
Create a reactive function outside the shiny app.
You could store all the shiny modules in a file modules.R and add a global.R script to each of the apps that loads the modules (source("../modules.R"). Then you only have to update the functions within modules.R. That change of structure might take a while in the beginning. But, i think in the long run it pays off for more complex apps.
I ended up making a library that contained most of the code I needed for the apps, as suggested by Adam Spannbauer in the comments.
It's not perfect; I still have some duplication and I have to have the library on GitHub so that it will work with shinyapps.io. However, it's a big improvement on what I was doing previously.
I am currently using meteorhacks:ssr along with wkhtmltopdf in order to generate downloadable pdfs within my Meteor app. It is working end-to-end, which is great, apart from one last element.
The template helpers which have been specified in packages across my app, are not visible. From the examples in the documentation for SSR it uses templates and helpers specified at a super-package level, which is not feasible with a package based arrangement for an app.
The only way I can see to make them available both client and server-side is to store the functions in an object, and then to loop through the helper functions in client and server code to render the functions accessible in both places.
That methodology works, but it is rather lacking in beauty. Does anyone have any other experience/ideas with this?
I have a complex R script which contains many new declared functions. These functions are able to check and clear given file under some requirements.
I want to prepare a simple user interface, where people without any knowledge about R will be able to upload source file, choose some options, and download analysed file without looking into a code.
I prepared a simple shiny app which contains my archival R code in the past, however each time when I want to perform some calculations, I had to use reactive() and add () after each variable.
This time, script is too complex to adjust it to reactive() form.
Is there any way to implement whole R script with avoid this?