Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

shiny

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.

like image 615
user2522217 Avatar asked Aug 15 '13 22:08

user2522217


2 Answers

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.

like image 198
Victor K. Avatar answered Oct 11 '22 16:10

Victor K.


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.

like image 23
Dirk Eddelbuettel Avatar answered Oct 11 '22 15:10

Dirk Eddelbuettel