How to run R scripts on server from web interface - r

There are a few R scripts that several analysts in an organization need to use in their daily life in order to get some analysis and reports.
I was planning to create a Shiny app so that the scripts would be able to run on a server with more memory and processing power, as well as for having some validation of the inputs with selectable or dropdown fields, as now the inputs are typed manually and this creates a lot of errors.
But there are a few problems with this approach (as far as I know):
1) Shiny disconnects when users closes browser or connection, what would finish the execution of the scripts (they can take several hours to run)
2) Once a script is launched it blocks the whole Shiny for doing other tasks (I have unsuccessfully tried to set up parallel computing... we have Windows servers).
Are there any solutions for the issues above to keep on using Shiny?
Maybe Shiny is not the best system for this? Are there any alternatives?
Thanks

I can't tell you for shiny, but in general there are 2 tools I can recommend for it: rundeck and script-server. Both of them can execute any type of scripts and provide web UI for the script with required inputs, script output, logging, etc.
disclaimer: I'm the owner of the script-server project

Related

How to speed up loading data at start of shiny app

I'm pretty new to using shiny apps to visualize data. We plan to host our shiny app on our own server. So for that we used docker to deploy our app. However the app is super slow to load, since we have to load a lot of (big) dataframes (up to 10000000 rows x 10 columns), that are saved within a RData object.
My first question is: Will the data be loaded each time a user visits/reloads the website?
I was looking into ways how to spead up loading the data. One possbility might be to use the feather package, which seems to be faster in loading data tables.
Another option would be to put the data into a database. However I do not have experience with that. I saw there are some nice packages like DBI and RMariaDB that seem to work well with shiny app. However, I only find examples where an exterinal database is queried. Is it possible to pack a MySQL database within the docker and access it from within the shiny app? Or is the normal procedure to host the database externally?
I'm really new to all this, so I'm not even sure if I'm asking the right questions. These are the conditions: We have a lot of data in the form of multiple data tables. Those need to be read into our app quickly and needs to be queried quickly through interactive user input. We need to dockerize our app in order to deploy it. What is the best approach here?

Possibility of getting offline shinyApp without Publish Button, csv Data and seeing R code?

Hi guys i have made a shinyApp for a client using R.
The client for whom I’m working is asking for a shinyapp that works offline preferably in the form of an application or shiny window (as the online link of shinyapp.io will put load on the server). He wants to get the shiny output without seeing the R code.
He will later handover the shinyApp to his employees (>200) and they will mostly use the offline shinyApp on their desktop (in shiny window). Furthermore the data is very confidential so the client doesn't want his employees to either get csv data or publish the app online or see R code. Because every time they would run the app, they require csv data or codes to generate output.
That's why he doesn’t want a publish button anywhere in the app so that his employees doesn’t publish the app online.
Is there any way to do so? Any suggestions would be much appreciated
Method 1
I feel this is the best way to do it. This will give you an exe setup to install on your clients' server If you find it complicated you can try the below method, but my first preference would be this one.
Method 2
The process of making your standalone app is best explained here.
You can also use this site. If you feel the first is a little ambiguous
It is very much possible, and I do it often. If you have any doubts, you can ask me. This will not show the code to your client, it will be like any other desktop/server app, although the code can be seen if the app is probed, unlike the first method.
You can put the packaged app in a server which serves the local IPs.
I think you can do it without any hassle. Just follow the instructions line by line.
Regards/Revanth Nemani

How to clear outputted values in shiny app

I have a shiny app with a lot of different outputs (data preparation functions, clustering, modeling etc.), and when the user uploads a file some of them start calculating. Therefore there is a problem when he decides to upload a different file without refreshing the page: due to bad architecture a lot of outputs that depend on reactives crash the app. So here is a question: is there a way to clear cache (if you can call it so) in a shiny app?

Deploy Shiny app that can read files from local computer (no possible Data-based solution)

I am trying to deploy a Shiny app on shinyapps, but it is not possible to read and write local files from the computer of the user. The idea is that every user can upload some datasets and images given a local path where this input is stored, not to have a same series of inputs for everyone stored in a ´Data´ folder.
I know there are other options to deploy shiny apps (amazon, shiny server), but I am afraid I will find the same kind of problems. Before losing too much time trying other approaches, I would like to know if there is any way to deploy a shiny app that can read these inputs given a local path and, if not, if there is an easy way to prepare an online app that can do this trasnlating from a shiny-based one. If not, I guess I will have to leave my app as a normal R package.
Thank you in advance.

Rscript + PHP exec() command vs rapache

Say I want to have a simple web app that takes some user input, performs a quick calculation in some predefined R script, and returns some cool looking graphic with say ggplot. One way to do this would be:
Have PHP accept some input from a web form
Sanitize the user input in PHP
Send the arguments to some pre-written R script using some combination of the PHP exec() command and Rscript
R does some calculations and saves the plot graphic to the server as well as some meta info to a MySQL database
The client can then access their cool new graphic from their web browser
This seems fairly straight forward to me. Thus my question is, what advantages would the rapache package have over the process described?
First off, rapache is not a package. It's an apache module and a set of conventions, really a system, for creating web applications written in R...
The advantage is speed. The disadvantage is you'd have to write a bunch of R code. Some might disagree with me on that one, though.

Resources