Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serve a R code that produces a Shiny app in your local shiny server

Tags:

r

shiny

I have the following R code from (BatchQC package)

 library(BatchQC)
    nbatch <- 3
    ncond <- 2
    npercond <- 10
    data.matrix <- rnaseq_sim(ngenes=50, nbatch=nbatch, ncond=ncond, npercond=
        npercond, basemean=10000, ggstep=50, bbstep=2000, ccstep=800, 
    basedisp=100, bdispstep=-10, swvar=1000, seed=1234)
batch <- rep(1:nbatch, each=ncond*npercond)
condition <- rep(rep(1:ncond, each=npercond), nbatch)
batchQC(data.matrix, batch=batch, condition=condition, 
        report_file="batchqc_report.html", report_dir=".", 
        report_option_binary="111111111",
        view_report=FALSE, interactive=TRUE, batchqc_output=TRUE)

When run in RStudio console, it produces this:

enter image description here

My question is how can I show that site through my local Shiny Server

/srv/shiny-server/
like image 510
pdubois Avatar asked Oct 29 '22 06:10

pdubois


2 Answers

what do you mean with local shiny server? when you run a preview from R that's local already. if you have a full shiny server install on your machine, just create a folder in sample-apps and then point the browser to the shiny server (usually http://127.0.0.1:3838/sample-apps/youfolder/

like image 177
lorenzov Avatar answered Nov 15 '22 06:11

lorenzov


I'm not familiar with that BatchQC package, but assuming it's this one on GitHub, I looked at the batchQC function and saw this code:

    appDir <- system.file("shiny", "BatchQC", package = "BatchQC")
    if (appDir == "") {
        stop("Could not find shiny directory. Try re-installing BatchQC.", 
            call. = FALSE)
    }
    shiny::runApp(appDir, display.mode = "normal")

So, I don't know if this will work or not (I wasn't able to install the package myself), but you can try to create an app.R file in your shiny server with the following lines:

appDir <- system.file("shiny", "BatchQC", package = "BatchQC")
shiny::runApp(appDir)

Can't guarantee it'll work, but try it out.

like image 44
DeanAttali Avatar answered Nov 15 '22 05:11

DeanAttali