R Markdown 与 Shiny Server 更改主机参数 [英] R Markdown with Shiny Server change host parameter
问题描述
我在服务器上运行 RStudio,并创建了一个 RMarkdown (.Rmd) 文件.如果我将它创建为静态 HTML,它工作正常,但如果我希望它是交互式的(通过添加 runtime:shiny),它就不起作用.
I am running RStudio on a server and I created a RMarkdown (.Rmd) file. It works fine if I create it as a static HTML but it does not work if I want it to be interactive (by adding runtime:shiny).
问题是,当我添加 runtime:shiny 并按下 Run Document 按钮时,应用程序将尝试在 127.0.0.1:xxxx(这里 xxxx 是一个随机端口)打开.为了使其工作,我必须能够将主机参数更改为0.0.0.0".这是 shiny 包中 runApp 函数中的一个选项,但我不知道如何在 RMarkdown 中添加此选项.
The issue is that when I add runtime:shiny and press the Run Document button the application will try to open at 127.0.0.1:xxxx (here xxxx is a random port). In order to make it work I would have to be able to change the host parameter to '0.0.0.0'. This is an option in the runApp function from the shiny package but I don't know how to add this option in RMarkdown.
谁能帮我解决这个问题?
Can anyone help me with this?
谢谢.
推荐答案
来自 rmarkdown
的 ::run
命令调用 shiny::runApp
内部.您可以在运行文档之前设置选项shiny.host
:
The ::run
command from rmarkdown
invokes shiny::runApp
internally. You can set the option shiny.host
before running the document:
options(shiny.host="0.0.0.0")
rmarkdown::run("myfile.Rmd")
您还可以将任意参数传递给 runApp
,所以这也应该有效:
You an also pass arbitrary paramters to runApp
, so this should work too:
rmarkdown::run("myfile.Rmd", shiny_args=list(host="0.0.0.0"))
这些都不适用于运行文档"按钮;该按钮启动一个新的 R 会话,在其中呈现文档.要在该会话中更改 shiny.host
选项,您需要将该选项添加到您的 .Rprofile
.
Neither of these will work with the Run Document button; that button starts a new R session in which to render the document. To change the shiny.host
option in that session, you'll need to add the option to your .Rprofile
.
这篇关于R Markdown 与 Shiny Server 更改主机参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!