Interactive Document (takes input gives output) in Rpubs - r

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.

Related

Can automated PDF reports based on template be made in Plotly Dash or R Shiny?

I work for a company that runs market research surveys for clients. Hundreds of different clients participate in each survey, so they do not all get an individual report. Instead, we have a report template in PowerPoint which is the same for all clients, and then we use a program called E-Tabs Enterprise to populate the template for each client with that client's own survey results.
These reports are typically about 100 slides long, and contain a mixture of static text and images, which are the same for all clients, and survey results, which vary between different clients. The reports are sent as a PowerPoint or as a PDF to clients via an FTP.
To increase efficiency, I want to switch either to Python Plotly Dash or RStudio Shiny to create static PDF reports (although I will also be interested in making dashboards in the future). I am trying to see which, if either of these, has the capabilities I need. I am already competent at Python Pandas.
It is clear from the Shiny website (link here: https://shiny.rstudio.com/articles/) that Shiny can make a report and export it as a static PDF. However, I have two questions:
Can the open-source version of Plotly Dash also be used to create a report and export it as a PDF?
Is it possible, within (open-source) Shiny or Dash, for the code to loop through the data for the different clients and export each as a separate PDF?
If this is not possible, could you please tell me what the limitations are and whether it is possible in the paid versions of the two programs?
Please let me know if my question is in any way unclear. I would also be open to recommendations for other software if there is something out there more suitable for what I need. Thank you for your help in advance.
Kind regards
Thank you for your answers. I can see that RMarkdown has the capabilities I need. It seems that there is no good equivalent of RMarkdown in Python at present, unfortunately, so RMarkdown is the right tool to use.

auto documentation system for R shiny

I ask for any advice how to do documentaion / auto-documentation for larger shiny applications.
R packages have roxygen2, but are there any equivalents of auto-documentation for shiny server and ui code?
I'm working on a developing project of +15k lines of code and we push as much as possible to packages with roxygen2 docs, however all of the observes and reacts in central server script and its subscripts are not auto-documented. I also use git of course.
I have tried to tag every observe, reactive, module etc in source code with a unique ID and draw a diagram manually with corresponding IDs. The diagram describe what type of sub-element and topic. Later I would add all triggers etc. This process is very manual though. Maybe I could use "the reactive log" https://shiny.rstudio.com/articles/debugging.html to autogenerate such documentation?
...update 1: I have tried ShinyTester which reads through source code and try to predict a network of sub-element interactions. It did not handle sourcing of external files, but with a little debug I manage to get the below diagram. Unfortunately, only 5% of elements and interactions were discovered hereby. Maybe ShinyTester could need some contributions. :

Workflow for maintaining different versions of a Shiny app

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.

Shiny or just htmlwidgets

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.

Implement whole R script contains functions into shiny

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?

Resources