Start project as Shiny app or Shiny markdown document? - r

I'm an experienced programmer but new to R, working on a visualization project that would be months of work in D3.js (but client knows R, not JavaScript.) I may have to start from a clean slate again once I figure out what I'm doing, but at the moment, I'm just trying to decide what kind of object to start with. If I make a new R Markdown document (in RStudio), Shiny is one of my output options; or I can make a new Shiny app without markdown.
I can guess what some of the trade offs might be:
R Markdown might be a good playground for trying stuff, documenting it
as I go along, and sharing it with clients.
But the quoting and embedding options add an extra layer of stuff I'm
not proficient with.
Working on a plain Shiny app might allow me to focus more on learning
Shiny, but it might tempt me to over-design the app before I know what
I'm doing, and I should probably be focusing more on learning R and
ggplot2 and experimenting with the data and possible Shiny widgets (which
R Markdown should be good for.)
The question of what I should do is opinion-based, and I understand that's not what StackOverflow is for. But just writing out the question has helped me understand the differences between these options. So my real question is: have I understood the relationship between Shiny and R Markdown correctly or am I missing something important?
Edit. Based on clarifying questions in comments, my needs are: a good playground for learning R, exploring the data and ways of letting users interact with it, documenting these experiments, and serving as a scratchpad for components that will form a more coherent application eventually. Based on this question, R Notebook might be more appropriate for a first pass than regular R Markdown, but it doesn't have a prepackaged Shiny option, so R Markdown with Shiny is probably best for now.

Related

Interactive Document (takes input gives output) in Rpubs

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.

What is the best way to include word document editing into R markdown workflow?

I am writing my masters thesis currently in R with Rmarkdown. While I love the writing style and ease of referencing I am worried about how revisions and comments from my supervisors will integrate into my workflow. Some of my supervisors have no R experience so there is no option to collaborate through GitHub. I was wondering if what the best way for me to write in R but edit and revise in Word would be.
The only way I can think of is publishing to a word doc and sharing with supervisors for them to comment and make changes with track changes / myself edit with grammarly. I would then manually make all the changes inside R.
This seems ridiculously time consuming, hopefully someone has an idea?

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.

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.

R statistics console in QT

I am planning to link a Qt project against R to provide some statistical funcionality. I thought it might be quite cute to add some generality to the project by having an R console as a Qt widget within the tab to allow me to do analyses that I haven't thought of in the design stage later on. I was wondering whether it is something that might be accomplished fairly easily?
In particular I'm stuck on how I would access the RTerm from QT? Has anyone else attempted something similar or can give some hints on where to start?
One of the examples for RInside does something pretty close---in around 200 lines most of which deal with the other GUI aspects, it wraps R functionality inside a Qt application.
The example implements a GUI density slider, and the edit box allows you to write an almost arbitrary R expression, or rather the parts that are then passed into an evaluation to generate random number: rnorm(50), or for a mixture c(rnorm(50), rt(50)) etc. You could possibly build on top of that.
See this blog post for more.
Check out Carson Farmer's work on manageR:
http://www.ftools.ca/manageR/
this is a plugin for Quantum GIS (mapping package) that interfaces it to R, giving you exactly what you want - an R console wrapped in a Qt4 body - as well as data transfer between Qgis and R. It handles plots as well.
I've tried to encourage Carson to produce a standalone R Gui project from this code, but he's a busy guy. Aren't we all?
RStudio is largely written using QT, you should be able to have a look at their code and build something similar into your Qt based application:
https://github.com/rstudio/rstudio

Resources