Embedding apps in website

I'm a bit confused by the different options available for deploying Shiny apps.

I'm interested in making data openly available for a study published in an academic journal, and I would like to provide the visitor with an interactive version of the paper's figures so that they can play with the parameters or download the results most relevant to them.

This being an academic project, I do not want / cannot afford to purchase an expensive Pro/commercial licence (a cheap one might be OK if it scales well with our limited usage). It's unlikely to draw much traffic, so a basic plan would be more than enough. Ideally, we'd like to make the app available on our group's website, and perhaps host it on our own servers (if I can convince our IT department) to get more control.

From what I've seen it looks like a shinyapps.io app embedded in an iframe would be our best option at present, but I'd be curious to hear of other experiences with Rstudio Server in an academic/non-commercial setting.

4 Likes

I use the free and open source version of shiny server and embed the apps in an iframe (when needed). I just pay the fee for hosting the server, which can be as low as $5/month or probably even free if you are using University resources. I've tried using the free tiers on AWS and Google cloud, but they are a bit too lean for shiny apps IMO. Going up to the $5 /month options tends to be good enough (though so as much processing beforehand as possible to reduce compute time in the app). shinyapps.io is useful if you don't want to install shiny server yourself or don't want/have dedicated servers. Otherwise, you'll get better performance from hosting yourself.

That price range also opens up a wide set of options for cloud providers. If you aren't locked into one, my favorites are digital ocean and Google cloud. DO has amazing tutorials and a dead simple interface with good bang for buck value. Google has amazing *aaS options for data science and gives you $300 free credit to start and has free tiers on most of their offerings. AWS has by far the most offerings, but it's a pain to use and their UI/UX is pretty much the worst of all the main options MN

4 Likes

Thanks for sharing your experience. It sounds like I'm better off starting easy with shinyapps, and later on – if necessary – upgrade to private server hosting if our Uni offers one, or learn how to deploy over a third-party server somewhere on the cloud.

2 Likes

If you're interested in spinning up a server and configuring shiny server, I'd recommend Dean Attali's walk through for doing it on Digital Ocean (though this could apply to any server). I've used it twice in the last few months, once at work and once for a personal shiny server + RStudio Server. Here's the link:

6 Likes

Yes, that's a good interpretation of my longer than necessary rant. :upside_down_face:

This tutorial is great, but also works pretty much line for line on any cloud provider. I highly recommend trying out a few because while they all give you pretty much the same thing, they all feel really different to use.

Like I said previously, digital ocean is one of my personal faves though.

2 Likes

Same problem!

I've tried to use Shiny Server on our department server, but not successfully. For now I've tried to use Docker on our server, but again the server for some reason is super secured, so my app can't download data from outside (expectation, reality). So for now... I've succeed only with the shinyapps.io.

Yep it can work the exact same on any similar VPS provider. I just like DigitalOcean's UI, I think it's a lot more friendly to non technical people and less intimidating for anyone who has no experience with such services

1 Like

I've recently migrated a Shiny app over from the free shinyapps.io tier to a free AWS instance (which usually costs about US$10 a month). They're roughly the same in terms of performance: we served around 800 people on the first day, and I never saw the CPU go above 15% in the console. I do notice that update times tended to slow (from a second or so to 4 or so seconds) when more than a few people were using it at once.

The AWS console is incredibly intimidating :weary:

1 Like

Regarding shinyapps, any html tips to display a temporary animation / static image while the app is loading inside a iframe? It's a little slow (couple of seconds), and a casual visitor might find a blank page off-putting and move one before it's loaded.

1 Like

@baptiste I have no idea whether his would work for a non-text output, but in our app we did the whole UI in HTML. Since that method only requires that you name your inputs and outputs using DOM attributes in order to bind them to the shiny code, we were able to just put default content (in our case, an ellipsis) inside the tag we were binding. Then, when the server function runs and we write to the output, the contents from the HTML file is replaced.

You could try doing this with a plot output—put an SVG or something in there and see whether it gets replaced (if it has the correct class, of course). No promises, though!

EDIT: here's our repo, if you'd like to see it in action. Check out app.r and www/index.html.

Thanks, but I think I'll need to stick with standard Shiny because I'm struggling as it is to get my head around the interactive behaviour, and I need plots and tables.

I'll have another look at css / js options to have a background image while the iframe's loading, because currently it's quite empty: http://nano-optics.github.io/port

That's fair enough. Doing it all in HTML came more naturally to me, but I struggled with the lack of documentation on it :confused:

Another potential solution to this issue would be to ask the user to take an action (e.g., click a button) before returning any data or visualization. I prefer this approach as it reduces the cognitive load on the user by not throwing tables and charts at them before they've had a chance to orient themselves mentally on the page.

2 Likes

Yes, I use the shiny-cssloaders package in most of my shiny apps to let people know stuff is happening and to be chill for a bit. Alternatively there is shinysky which introduces loaders and other niceties for shiny apps. I like the former because it's prettier by default and imports less into my app, but try both out and see what you like.

2 Likes

Thanks, I quite like the style of shiny-cssloaders but unfortunately I only want the animation while the iframe is loading up, not every time the plots update (I find it distracting). I think it's not really a shiny-related problem though, more of a html/css trick.

I guess my issue is mostly the blank space before the shiny app even loads up into the iframe, so there's probably not much to do on the shiny side. Ideally I'd place a static screenshot of the app in the background; as you say it helps if the visitor gets a chance to orient themselves around the page before exploring the animation.

Edit: actually, this is pretty good: https://github.com/daattali/advanced-shiny/tree/master/loading-screen

3 Likes

Very useful walk-through, thanks again. I used it today to set things up on Amazon and it worked flawlessly (I had to ask our admin to open port 3838 but that's about it).

1 Like