Lightweight version of R and shiny for efficient app deployment? - r

Is there any way to make the R + shiny build smaller, so as to make it more light weight when deploying shiny apps? (or plumber API's, or any other R processes for that matter?)
Background
I have been deploying shiny apps in kubernetes and the builds are quite a lot larger than similar apps written in other languages (e.g. python).
I've also deployed some to heroku, and they're also quite large builds (in the hundreds of MB, whereas other similar apps in other languages might only be a few tens of MB).
What I know so far
I know base R is quite large, but packages are the bulk of the build size, so I have reduced those as much as possible by not importing anything unnecessary, and extracting some functions from their packages so as to not have to include the whole thing.

I think leprechaun is the best option (as in easy AND light) out there right now. It's purpose is to be similar to golem, but without making the heavy requirements of golem. (link to the docs https://github.com/devOpifex/leprechaun/tree/master/docs)

Related

Simple image operations for .NET Core 6 and beyond

I have some C# code that relies on doing really basic graphic operations such as getting and setting pixels, and drawing texts over images. This uses the System.Drawing package which Microsoft has dropped the ball on.
Microsoft says this: Migrate to one of the following libraries: ImageSharp, SkiaSharp, Microsoft.Maui.Graphics. The latter appears to be ill-documented and unstable.
Could anyone with experience with these packages suggest an easy and simple way forward?
I am even wondering if it might pay to write my own library for the Windows bitmap format (which is sufficient for my purposes).
Yours frustratingly...
It depends on which platform you are building your app, but SkiaSharp 2.80.2 or 2.80.3 can be a good choice. There are quite a bit problems in newer packages, so you need to be careful which version you install so that you do not run into performance problems or bugs.

Correct way to create a software install script which can manage dependencies

I'm currently working on an university research related software which uses statistical models in it in order to process some calculations around Item Response Theory. The entire source code was written in Go, whereas it communicates with a Rscript server to run scripts written in R and return the generated results. As expected, the software itself has some dependencies needed to work properly (one of them, as seen before, is to have R/Rscript installed and some of its packages).
Due to the fact I'm new to software development, I can't find a proper way to manage all these dependencies on Windows or Linux (but I'm prioritizing Windows right now). What I was thinking is to have a kind of script which checks if [for example] R is properly installed and, if so, if each used package is also installed. If everything went well, then the software could be installed without further problems.
My question is what's the best way to do anything like that and if it's possible to do the same for other possible dependencies, such as Python, Go and some of its libraries. I'm also open to hear suggestions if installing programming languages locally on the machine isn't the proper way to manage software dependencies, or if there's a most convenient way to do it aside from creating a script.
Sorry if any needed information is missing, I would also like to know.
Thanks in advance

Using R in Apache Spark

There are some options to access R libraries in Spark:
directly using sparkr
using language bindings like rpy2 or rscala
using standalone service like opencpu
It looks like SparkR is quite limited, OpenCPU requires keeping additional service and bindings can have stability issue. Is there something else specific to Spark architecture which make using any solution not easy.
Do you have any experience with integrating R and Spark you can share?
The main language for the project seems like an important factor.
If pyspark is a good way to use Spark for you (meaning that you are accessing Spark from Python) accessing R through rpy2 should not make much difference from using any other Python library with a C-extension.
There exist reports of users doing so (although with occasional questions such as How can I partition pyspark RDDs holding R functions or Can I connect an external (R) process to each pyspark worker during setup)
If R is your main language, helping the SparkR authors with feedback or contributions where you feel there are limitation would be way to go.
If your main language is Scala, rscala should be your first try.
While the combo pyspark + rpy2 would seem the most "established" (as in "uses the oldest and probably most-tried codebase"), this does not necessarily mean that it is the best solution (and young packages can evolve quickly). I'd assess first what is the preferred language for the project and try options from there.

Deploying an R app with a GUI [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I developed an R application and I want to deploy it.
Currently the application consists of a set of functions to be run from the command line, like an R package. In order to deploy it, I am thinking of repackaging R Portable adding the necessary libraries and my code to it. My main problem is choosing a proper GUI toolkit.
Production Environment
My app is a single-user one (i.e. a Desktop application) and the target platform is Windows. It could bootstrap in R and then call the toolkit, or bootstrap, say, in Java and then call the R engine. The GUI should first and foremost feed the app functions. It should also grab the function graphical output.
Possible Alternatives
Here is a potential list of alternatives. I’d like to know if they meet/fit the requisite environement described.
Java JRI is now released only as a part of rJava, but while the latter is clearly documented, I am unable to find docs and tutorials for the former.
As for Deducer, it is presented as a GUI front-end, but I found out that it is also a GUI toolkit
TCL/Tk bindings seem a natural choice for R and are well documented, but someone complains about limitations of this toolkit.
RGtk2 seems interesting and there are also some tutorials around.
gWidgets is one of the rare toolkits to sport a package vignette!
Despite I don’t need a real web application, an interesting option would be interfacing R with JavaScript/HTML. As most of us, I am familiar with this environment and the app could benefit of the many JS libraries.
The problem is that the beautiful Shiny server and rApache are for Linux only and this is probably true probably Concerto too. Instead Rserve runs on Windows and, while there is no official JS client, I found the third party rserve-js and also a node.js client.
Rook, by the same author of rApache, should be platform agnostic (isn't it?).
R Server Pages could work, but I didn't find examples on the functions HttpDaemon and HttpRequest in the vignette or reference manual.
I run some simple examples with gWidgetsWWW. It works, but it seems to produce canned web pages, without the possibility of modifying the HTML code.
EDIT
Let me clarify my question. I am not surveying your personal preferences.
The technologies or products mentioned here tend to be very young and not widespread. It would be very unpleasant to discover, after investing months of code, that they are not yet ready or don’t fit production. So I would like to know (not your subjective tastes, but) if they are able to work in the environment described above.
We have created a kind of webapp building on rApache and Ruby on Rails beside some other technologies at rapporter.net - that turned out to act rather a framework to host R-based statistical applications in the means of Rapplications instead of our initial goal to create a user-friendly online front-end to R. I'd warmly suggest to check out our features, as you might save tons of resources by not dealing with server-side, CMS and other boring issues, but could concentrate on the statistical tool.
Anyway, beside promoting our stuff, let me summarize my experiences:
rApache is definitely ready for production, but please note that only for rather stateless algorithms (by default Apache would start bunch of workers so the same user/client would end up interacting with different R sessions in each query). E.g. RServe would be a better alternative for a stateful application.
AFAIK Shiny server is meant to host dedicated statistical tools and applications -- just like our Rapplication service with or without DB backend -- with some customizable user input. You would need some technical skills to do so and also providing a (HA) environment might require way too much extra resources. This can be a huge advantage or disadvantage based on your requirements and expectations.
The hugest issue in such question should be security (like using RAppArmor or sandboxR), not just the R connector back-end, as users will interact with your servers (if hosted in the cloud). Desktop applications are a bit more developer-friendly, but supporting all major platforms can be a no-no in the era of tablets and smartphones. The cloud app can run on any device with a browser.
You should choose the optimal solution based on your requirements. There are bunch of tools ready for production, and each has its own advantages and special use cases. Just check out which related packages/applications are still under development with support, and answer a few questions like:
Is there any need to connect to databases?
What types of user input is needed (e.g. only parameters, datasets, R commands)?
Desktop/cloud app? Are you sure? If the later, would you like to care with the setup, maintenance and support?
Do you run any computational intensive tasks?
Do you want to implement an application to help users with repetitive and standardized tasks or rather providing a rather general and extensible software?
Do you need a responsive application with interactive setup or using that for reporting purposes?
What output formats do you need?
What other technologies are you familiar with? It's rather hard to built a Meteor-based app with a NoSQL backend if you worked with MySQL, PHP, Java or C# in the past.
I'm about to do something similar. The fastest way ( in respect of both deployment time and future application performance) seems to be c# interfacing with R through R.NET. In Visual Studio you will benefit from incredible visualisation options with just few clicks, and setting up interactive/drill down charts it's quite straightforward too. As you also mentioned, RServe (with Java) is another valuable option.
EDIT
If a web application is not required to run on a public ip address the r package Rook it's an interesting option. Some example with Rook: using ggplot2, using googleVis

Remote communication with R – How to start with an R GUI client to access R on a remote Server

I tried RInside's Qt example qdensity and really liked it. It was easy to setup and I was surprised how easy it was to understand and modify given that I have virtually no Qt experience. Now I wonder whether it is possible to use RInside with R somewhere on a remote machine.
It seems that I cannot use RInside for this purpose. I wonder whether there is another way of creating a Qt Desktop app, that communicates with R on some server. I got R Studio Server running and I am really happy with it, but it's for the R people. In order to promote my R stuff within our institute also among non-R people I would like to offer a simple, very limited GUI that can do basics things like showin' some graph or starting a R CMD Batch. I also know shiny (and shiny server) and have been actively testing it recently, but I am looking for a simple Desktop client go connect with my server-side R.
Is there a basis to start out with Rserve and Qt?
Any suggestions (where to start, examples, generally bad idea) ???
What are R's capabilities to handle something like this IPC or D-Bus stuff.
Use Qt with C++, and just process the files that you create with R on you're server.
So for example: create the graphic and save in a format that you can load. BMP, PNG etc. Load it to you're GUI.
Also I suggest Qt Creator for GUI design. Its fast and simple. This idea only fits you if you don't want to stay in in R environment.
When I have created programs that process data and calculate things like probabilities and charts, usually use HTML for the interface using PHP and leaving the rest of the processing (for example R scripts) to the server.
For any recent visitor: Take a look at openCPU, it publishes R functions as restful services and does all the marshalling from R data types from and to JSON.

Resources