How to run a shiny app as a standalone application? - r

I've some shiny app and I want to execute and to make it standalone application (it will be awesome if it will open via chrome).
I can't upload the app to the Net and I want that also co-workers without R studio or R
will use this app.
because of the security company - I can't download any software except R packages.
I saw here a few solution, but all of them included any software download.

I have done some research on this issue. The commenters are basically correct: you need the R binaries in some way, either a portable R or an R server. But there are solutions that allow it to bundle those with your code and hide the details from your users.
On option is to wrap your app along with
a portable R into a container application like Electron. The electron-quick-start project tries this.
The RInno package provides functions to bundle your app and R portable into an installer app. Every user runs the installer on their system once which will install your app, the packages and the code. But in the end users may not see the difference to other apps. They get a link in the start menu and that's it. I did that successfully. But it did not work out of the box. I had to adjust the output manually in several places.
A second container solution works with docker. That is what ShinyProxy does. See also this blog.
The package shinyShortcut (I quote) "will produce an executable file that runs the shiny app directly in the user's default browser".
Important to note: I haven't tested most of them. From reviewing the solutions I often get the feeling that these solutions might make releases somewhat complicated because there are always manual steps involved.

Related

Can people without R installed run an R Notebook file successfully?

I have an R Notebook that I am building to provide an analysis for somebody, and I am wondering if I should choose another option as I don't know if she will be able to run the Notebook without having R installed.
Is it possible to run an R Notebook as a single entity or must you have R installed in order to do it?
To rerun the notebook they require R. But the whole point of R Notebooks is that they produce a static document as output. That document (usually in HTML format) can be shared in isolation, and does not require any additional software besides a web browser to be viewerd.
Notebook will need R to run. To distribute a notebook without the R dependency will be a bit more elaborate, like installing rstudio server within a docker container. User will, in this particular case, need to have Docker installed and know how to start a container. From there on the user can interact with the code through a web browser.
Another option would be to use the cloud solution that some companies offer. It offers sharing functionality and you don't have to worry about the infrastructure or distribution of your work. There are some free plans that may work for you, but the real power is in premium features.

Shiny as Stand-Alone Program

I wrote a Shiny app, and now I need to turn it into a Stand-Alone Program. The reasoning behind this is that I need to share the app but can't do this with shinyapps.io or a server as I need the app to be able to access user's folders.
So far, I found these 2 tutorials: deploying-desktop-apps and packaging-your-shiny-app. Both of them (supposedly) work on Windows, but I have a Mac, and I want to app to be available for users of all systems, or at least Mac and Linux. Any thoughts and suggestions would be appreciated!
I actually tried to follow the tutorial mentioned above, and can't even install R-portable for my Mac. So I'm looking for something different.
Running a Virtual Machine to follow Windows tutorial is an option, but in this case, the app will be Windows-specific, and I don't want this.
This thread is really old I know, but I'm also trying to find answers on creating a standalone version of R for Mac.
This would support for
https://github.com/chasemc/electricShine
which supports Windows

What is the easiest way to create a webapp from an interactive Jupyter Notebook?

I have a Jupyter Notebook that plots some data and lets the user interact with it via a slider.
What would be the easiest way to make a web app with a similar functionality? (reusing as much of the code...)
I believe the easiest way is to use voilà.
After installing you just have to run:
voila <path-to-notebook> <options>
And you will have a server running your notebook as a web app, with all the input code omitted.
AppMode is "A Jupyter extension that turns notebooks into web applications".
From the README:
Appmode consist of a server-side and a notebook extension for Jupyter.
Together these two extensions provide the following features:
One can view any notebook in appmode by clicking on the Appmode button in the toolbar. Alternatively one can change the url from
baseurl/notebooks/foo.ipynb to baseurl/apps/foo.ipynb. This also
allows for direct links into appmode.
When a notebook is opened in appmode, all code cells are automatically executed. In order to present a clean UI, all code cells
are hidden and the markdown cells are read-only.
A notebook can be opened multiple times in appmode without interference. This is achieved by creating temporary copies of the
notebook for each active appmode view. Each appmode view has its
dedicated ipython kernel. When an appmode page is closed the kernel is
shutdown and the temporary copy gets removed.
To allow for passing information between notebooks via url parameters, the current url is injected into the variable
jupyter_notebook_url.
To be complete - there exists also https://www.streamlit.io/ .
I still dont understand the exact difference between voila and streamlit.
At the moment I just struggle with the possibility to re-run everything with new parameters... I have bad luck with voila still.
Edit: I see that streamlit requires a raw python, not .ipynb, this fact would mean that this answer is completely wrong, I will search a bit more on streamlit before further action/comment.
Edit2: Voila looks great. However, I found few things that uncover the underlying complexity and thus a troubles that may arise.
callbacks. Widgets work great in jupyter, but since it is not possible to re-run one cell, sometimes the logic must be modified to work in Voila.
interactive java objects need a special treatment, e.g. matplotlib has a cheap solution, but there was nothing for e.g. jsroot
links. It is easy to create (a file and) a download link in jupyter, Voila can also serve a file, but it needs another extra treatment.
After all, I pose myself a question - is it better to learn many tricks and modifications to jupyter or to use some other system? I am going to see if streamlit can give em some answer.
The Jupyter Dashboards Bundlers extension from the Jupyter Incubator is one way to do it while retaining interactivity.
EDIT: While pip installing this package will also install the cms package dependency, like dashboard_bundlers, cms needs to be explicitly enabled/quick-setup as a notebook extension for the dashboard tools to work.
#raphaelts has the right idea and should be the accepted answer. As of Dec 2019, Voila is the most appropriate method to deploy Jupyter notebooks to production as a stand alone webapp. Think internal datascience teams sharing their analytics workload with internal C-Suite teams using SPA stlye Notebooks with all the code hidden and custom GUI/interactions thrown in. Recently discussed on HN
https://news.ycombinator.com/item?id=20160634 and the official announcement from the Jupyter maintainer https://blog.jupyter.org/and-voil%C3%A0-f6a2c08a4a93enter link description here
As mentioned above, voilà is a very powerful tool which hides the input cells from your notebooks and therefore provides a clean interface. In order to deploy your notebook with voilà you need to follow the specific steps of your organization. But if you want to quickly run it on your machine, simply install it with pip install voila. Then you can enter start from the command-line: voila my_notebook.ipynb or use the "Voila" button which should have appeared in your Jupyter notebook.
Note, however, that using voilà is only one part of the story. You also need to build the required interactivity, ie. to set up how to respond to input changes. There are quite a few frameworks for this.
The simplest one is to use the interact function or the observe method from the Ipywidgets library. This is very direct, but things can easily get out of control as you start having more and more widgets and complexity.
There are complete frameworks, some of them mentioned above. E.g. streamlit, dash and holoviz. These are very powerful and suited for larger projects.
But if you want to keep it simple, I also recommend to check out autocalc. It is a very easy-to-use library, which lets you define the dependencies between your widgets/variables and let all the recalculation be triggered automatically. A tutorial can be found here.
Disclaimer: I am the author of the autocalc package.
The easiest way is to use the Mercury framework. You can reuse all your code. To convert the notebook to web app you will need to add the YAML header in the first cell of the notebook (very similar to R Markdown). The widgets are generated based on YAML. The end-user can tweak widgets values and click the Run button to execute the notebook from the top to the bottom. You can easily hide the notebook's code (if you want) by setting the show-code: False in the YAML. The example notebook and corresponding web app are below.
Example of the notebook with YAML header
Example web app generated from notebook with Mercury

Deploying R shiny app as a standalone application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 months ago.
The community reviewed whether to reopen this question 5 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have developed a RShiny application which I would like to share internally with my colleagues (Hosting the app on a server, is not an option at this stage).
I was exploring various options, and I came across a technique for bundling your app as a standalone desktop application, with an installer file, which you can then share & distribute. (The approach is explained here & here)
This is quite neat, because the users installing it need not have R (and any other required packages) to install and run the app (it has portable versions of R, chrome etc)
I was able to follow the approach and create a standalone desktop application, with an installer file, which I can now start sharing.
However, this is my concern:
Ideally, I would not want my users to be able to access the source code. Is there a way to restrict such access? In the tutorial (the first link that I posted), this is what the author says:
*
Lastly, keep in mind that your source code is easily accessible. If
this is a concern for you (e.g. if you are distributing to a client
that should not have access to the code) the best you can do is impede
access by first compiling the sensitive source code into a binary
package. That said, any user who knows R (and has sufficient intent)
can simply dump the code to the console.
*
Are there better, more fool-proof ways to impede access?
Thanks!
There is now a way to turn a Shiny app into a standalone Electron app (which is a desktop app, used for apps like Slack). To find out more, see this excellent presentation (YouTube) from useR 2018, which contains further links:
GitHub ColumbusCollaboratory: electron-quick-start
GitHub ColumbusCollaboratory: Photon. RStudio Add-in to build Shiny apps utilizing the Electron framework
#TravisHinkelman's blog "Deploying a Shiny app as a desktop application with Electron"
I'm not sure if it would be a great fit on the code obscurity question, but the RInno package is designed to help with the data security problem, i.e. when a company does not want to share their data with a third party. It also automates the process you referenced above and allows you to connect your app to GitHub/Bitbucket to push out updates to locally installed shiny apps via API calls on startup.
To get started:
install.packages("RInno")
require(RInno)
RInno::install_inno()
Then you just need to call two functions to create an installation framework:
create_app(app_name = "myapp", app_dir = "path/to/myapp")
compile_iss()
If you would like to include R for your co-workers who don't have it installed, add include_R = TRUE to create_app:
create_app(app_name = "myapp", app_dir = "path/to/myapp", include_R = TRUE)
It defaults to include shiny, magrittr and jsonlite, so if you are using other packages like ggplot2 or plotly, just add them to the pkgs argument. You can also include GitHub packages to the remotes argument:
create_app(
app_name = "myapp",
app_dir = "path/to/myapp"
pkgs = c("shiny", "jsonlite", "magrittr", "plotly", "ggplot2"),
remotes = c("talgalili/installr", "daattali/shinyjs"))
If you are interested in other features, check out FI Labs - RInno. If you'd like a guide on how to connect it to GitHub/Bitbucket check out the Continuous Installation guide :).
You might be interested in DesktopDeployR, a framework for deploying self-contained R-based applications to the desktop.
https://github.com/wleepang/DesktopDeployR
I'm not familiar with that approach, is it common? I personally haven't ever seen it. It looks like essentially what you're doing is bundling R, Shiny, a web browser, and your code, into a file. It's as if the client installs R, Chrome, shiny, and runs your code, but he just does it all in one click. You're literally giving the user your code. I don't know how it works, but if the author himself claimed that the client will be able to see the source code, then that makes sense to me and I don't think you can avoid that.
Why not just host the file on a shiny server or shinyapps.io? The client won't see your code then. Also, is it really that important that they can't see your code? A lot of times people are afraid of others seeing their code but in reality nobody really cares to look at others people's code and steal it. Unless you have some very proprietary and advanced patented code.
You can also run your shiny app from a ".bat" executable file with code that runs your app from the command line.
Just open a txt editor and add the following line:
R -e "shiny::runApp('app.R',launch.browser=TRUE)
You can save it as, for example "test.bat". Rename app.R to whatever your shiny app name is. Make sure you have the launch browser set to TRUE, otherwise the app will only be "listening".
If you want to make sure any Rmd reporting works smoothly, also add the pandoc path to the code of your shiny app. For example add the line:
Sys.setenv(RSTUDIO_PANDOC="C:/Program Files/RStudio/bin/pandoc")
You can get your pandoc path by running: rmarkdown::find_pandoc()
Also make sure R is in your path environment (e.g. add "C:\Program Files\R\R-4.1.0\bin" to your path environment)
Users will have access to your source code if they really want to and R needs to be installed on the PC that runs the bat file, but it might be a nice way to quickly deploy a shinyapp, for instance, for small teams that have a shared workstation. And you don't need to pay for or install a server.

How can I enable auto-updates in a Qt cross-platform application?

I love applications that are able to update themselves without any effort from the user (think: Sparkle framework for Mac). Is there any code/library I can leverage to do this in a Qt application, without having to worry about the OS details?
At least for Windows, Mac and user-owned Linux binaries.
I could integrate Sparkle on the Mac version, code something for the Linux case (only for a standalone, user-owned binary; I won't mess with distribution packaging, if my program is ever packaged), and find someone to help me on the Windows side, but that's horribly painful.
It is not a complete solution, but a cross-platform (Windows, Mac, Linux) tool for creating packages for auto-updates and installing them is available at https://github.com/mendeley/Update-Installer. This tool does not deal with publishing updates or downloading them.
This was written for use with a Qt-based application but to make the update installer small, standalone and easy to build, the installer uses only standard system libraries (C++ runtime, pthreads/libz/libbz2 on Linux/Mac, Win32 API on Windows, Cocoa on Mac, GTK with fallback on Linux). This simplifies delivering updates which include new versions of Qt and other non-system libraries that your application may depend on.
Before considering this though, I would suggest:
If you are only building for two platforms, consider using standard and well-tested auto-update frameworks for those platforms - eg. Sparkle on Mac, Google's Omaha on Windows or auto-update systems built into popular install frameworks (eg. InstallShield). I haven't tried BitRock.
On Mac, the Mac App Store may be a good option. See https://bugreports.qt.io/browse/QTBUG-16549 though.
On Linux, consider creating a .deb package and a simple repository to host it. Once users have a repository set up, the system-wide software update tools will take care of checking for and installing new releases. The steps for setting up a new repository however are too complex for many new Ubuntu/Debian users. What we did, and also what Dropbox and Google have done, is to create a .deb package which sets up the repository as part of the package installation.
A few other notes on creating an updater:
On Windows Vista/7, if the application is installed system-wide (eg. in C:\Program Files\$APPNAME) your users will see a scary UAC prompt when the updater tries to obtain permissions to write to the install directory. This can be avoided either by installing to a user-writable directory (I gather that this is what Google Chrome does) or by obtaining an Authenticode certificate and using it to sign the updater binary.
On Windows Vista/7, an application .exe or DLL cannot be deleted if in use, but the updater can move the existing .exe/DLL out of the way into a temporary directory and schedule it for deletion on the next reboot.
On Ubuntu, 3rd-party repositories are disabled after distribution updates. Google works around this by creating a cron-job to re-add the repository if necessary.
Shameless plug: Fervor, a simple multiplatform (Qt-based) application autoupdater inspired by Sparkle.
Shameless plug: this a relatively old question, but I thought that it may be useful to mention a library that I created recently, which I named "QSimpleUpdater". Aside from notifying you if there's a newer version, it allows you to download the change log in any format (such as HTML or RTF) and download the updates directly from your application using a dialog.
As you may expect from a Qt project, it works on any platform supported by Qt (tested on Windows, Mac & Linux).
Links:
Website
GitHub repository
Screenshot:
Though it works a bit differently than Sparkle, BitRock InstallBuilder contains an autoupdater written in Qt that can be used independently (disclaimer, I am the original BitRock developer). It is a commercial app, but we have free licenses for open source projects.
I've developed an auto-updater library which works beautifully on Mac OS X, Linux and pretty much every Unix that allows you to unlink a file while the file is still open. The reason being that I simply extracted the downloaded package on top of the existing application. Unfortunately, because I relied on this functionality, I ran into problems on Windows as Windows does not let you unlink an open file.
The only alternative I could find is to use MoveFileEx with the replace on reboot flag, but that is awful.
However, renaming the working directory of the application works on Windows 7 and Windows XP. I haven't tried Windows Vista yet.
I have found WebUpdate to be quite useful, though it's written with the wxWidgets. But don't worry, it's a separate app which handles your updates. The steps to integrate it are pretty simple - just write two XML files and run the updater. And yes, it's cross-platform.
The advantage of it is it will automatically download and unzip/install all you required and not just provide a popup with a notification about a new version and a link to download it. Another thing you can do with it is customizable actions.
Project's main page is here, you can read the docs or take a look at the official tutorial.
The blog post Mixing Cocoa and Qt may solve the problem for the Mac platform.
You can use UpdateNode which gives you all the possibilities to update your software. It's using a cross platform Qt client and is free for Open Source!
UPDATE
Just did some further analysis on that and really like this solution:
Pros:
Free for Open Source!!! Even the client is Open Source: https://github.com/updatenode/unclient
The client is already localized in several languages
Very flexible in terms of updates. You can even update single non-binaries.
Provides additionally a way to display messages though the client.
Ready to use binaries & installer for all common Linux distributions, single Windows binary, as well as installer and a solution for Mac (which I have not tried, as I don't have a Mac)
Easy to use web service, nice statistics and update check is integrated within few minutes
Cons:
I am missing a multi-user management in the online service. Maybe they will do it in future - I will definitely suggest that in their feedback portal
The client is a GUI client only - so, you will need to shrink it down to run without a GUI frontend (maybe only necessary for people like me ;-) )
So, bottom line, as this solution is quite new, I think there is lot of potential here. I will definitely use it in my project and I am looking forward for more from them! Thumbs up!
This is an old question but there is not Squirrel in answers which is BEST SOLUTION , here is what I'm doing in qt 5.12.4 with qt quick "my qml app" you can do this in any other language
I'm doing this in windows there is mac version of squirrel too, I don't know about Linux
download nuget package explorer release
https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/releases
open nuget package explorer and add this directory 'lib/net45' it doesn't matter you have a .net app or not, I did this for my qt application otherwise it won't work.
add all files into this folder specify your version in the metadata
save nupkg file
download squirrel release https://github.com/Squirrel/Squirrel.Windows/releases
add squirrel to windows environment path
open cmd and cd to directory of nupkg file
squirrel --releasify file_name.nupkg -> now inide releases folder, there should be setup.exe file which will install app and other files.
to create new version do 2,3,4,7,8 again if its an update it will create delta file which is only needed file to update, put this files into your service directory for example in updates folder of your website which you need to disable directory browsing in IIS , and to auto-update application you need to call Update.exe which is in parent folder of application root directory appdir/../update.exe --update http://yourserver.com/upates/ after application restart app should start with new version
you can find documentation for squirrel in https://github.com/Squirrel/Squirrel.Windows/blob/develop/docs/getting-started/0-overview.md and nuget package explorer here https://github.com/NuGetPackageExplorer/NuGetPackageExplorer and you can use only nuget.exe too if you don't want to use nuget package explorer which can be used for dynamic generation of versions, which can be download from https://www.nuget.org/downloads
That easy. Now you have auto-update app which will download updates from the server and auto-update app. For more info you can read documentations.
note: for iis uses https://github.com/Squirrel/OldSquirrelForWindows/issues/205
I suggest you read on plugin and how to create and use them. If your application architecture is modular and be split into different plugins. Take a look at Google Auto Update utility http://code.google.com/p/omaha/. We use this.
Thibault Cuvelier is writing a tutorial (in French) to develop an updater. I know the explanations are in French (and everyone is not understanding French), but I think this can be readable with a web translator like Google Translate. With this you will have a cross-platform updater, but you need to write it by yourself.
For what I know, the only part of the updater that is explained in the tutorial, is the file downloading part. In the case this can help you, refer to the tutorial, Un updater avec Qt.
I hope that helps.
OK, so I guess I take it as a "no (cross-platform) way". It's too bad!
I have found a solution that can be automated with built-in self-extracting patches and updates. for windows. I have started using their sdk. take a look at the massive documentation here, https://agersoftware.com/docs/ the sdk is called securesdk and comes with their app, SecureDelta sdk. does a great job on any kind of files, better results than lzma-included delta updaters

Resources