如何在本地的Shiny服务器上提供生成Shiny应用程序的R代码

5

我有以下来自BatchQC软件包的R代码:

 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)

在RStudio控制台中运行,会产生以下结果:

enter image description here

我的问题是如何通过本地Shiny Server显示该网站

/srv/shiny-server/

你需要一台安装了Shiny Server的机器,并将你的Shiny代码移动到该机器下/srv/shiny-server/文件夹中。如果需要,我可以提供相关指导:http://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/(免责声明:这是我的博客) - DeanAttali
@DeanAttali 我已经有了Shiny服务器,并经常制作应用程序并将其符号链接到它。但是这个OP不同。请参见我下面对lorenzov的回答。 - pdubois
啊,我明白了。我会写出一个可能有效的答案。 - DeanAttali
这里只是一个想法:你的浏览器截图顶部显示了文件夹路径。那个功能是否在该文件夹中创建自己的(临时?)shiny应用程序?如果是这样,您可以从那里获取它并将其复制到/srv/shiny-server文件夹中,以便shiny以正常方式看到它。 - rosscova
2个回答

1
我不熟悉 BatchQC 这个软件包,但假设它是 GitHub 上的这个, 我查看了 batchQC 函数并看到了以下代码:
    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")

所以,我不知道这是否有效(我自己无法安装该软件包),但您可以尝试在您的闪亮服务器上创建一个 app.R 文件,并使用以下代码:

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

无法保证其可行性,但请尝试一下。

1
当你在R中运行预览时,本地闪亮服务器是什么意思?如果您在计算机上安装了完整的闪亮服务器,请在sample-apps中创建一个文件夹,然后将浏览器指向闪亮服务器(通常为http://127.0.0.1:3838/sample-apps/youfolder/)。

你提到的文件夹应该包含“Rmd”文件或ui.Rserver.R。但是我的代码是一个函数包装器,用于shiny应用程序。请尝试在我的原始帖子中使用命令以查看我的意思。 - pdubois

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接