user2522217
user2522217

Reputation: 355

How can I run my shiny app without calling library("shiny") beforehand?

I apologize for this extremely noobish question, but I can't find the answer. I just finished writing my R Shiny app and am preparing to send it off to my network guy so he can load it on my company server.

However, to run my app, I currently have to do the commands:

>library("shiny")
>runApp("myApp")

I don't want the network guy to have to deal with running library("shiny"), so how can I put this in my code? I already have

library(shiny) 

in my server.R

In addition, I have many packages implemented, including googleVis, ggplot2, and reshape2. I have these as

library(reshape2)
library(googleVis)
library(ggplot2)

But when using my app on a new computer I have to use 'install.packages()'. Will my network guy or app users have to worry about this?

Thanks.

Upvotes: 12

Views: 7642

Answers (2)

Victor K.
Victor K.

Reputation: 4094

Assuming you have shiny package installed on the company's server, you can just call

shiny::runApp()

What :: does is bringing a symbol from a package that hasn't being imported yet.

I have the following shell script runapp which lets me run shiny apps from the command line:

#!/bin/bash
R -e "shiny::runApp('$1')"

So I can say runapp directory-with-shiny-script/ and it runs the app.

Upvotes: 19

Dirk is no longer here
Dirk is no longer here

Reputation: 368181

You can't. It's like asking how to run R without R.

And yes, to run the code on a new computer, you will have to provide its dependencies.

Upvotes: 2

Related Questions