【发布时间】:2015-08-10 15:40:22
【问题描述】:
我想用 html/css 从头开始定制我闪亮的应用程序。因此,我使用 index.html 而不是 ui.r,我遇到了以下问题:
我在我的 ui.r 中使用动态输入,例如:
selectInput("var","Date",choices = format(Sys.time(),'%Y-%m-%d'))
翻译为:
<div class="form-group shiny-input-container">
<label class="control-label" for="var">Date</label>
<div>
<select id="var"><option value="2015-08-10" selected>2015-08-10</option></select>
<script type="application/json" data-for="var" data-nonempty="">{}</script>
</div>
</div>
由于我必须使用 Sys.time() 而不是 html 代码中的实际日期,我很想知道是否可以在仅使用 .html 作为 ui 时调用 R/shiny?
【问题讨论】:
-
您可以尝试在 html 文件中添加
uiOutputdiv,而不是使用selectInput,并从应用程序的server.R部分添加selectInput和Sys.time()。请参阅动态创建控件...部分here -
非常感谢您的建议。所以我可以在 server.r 中创建 html 输出,例如:
output$date <- renderUI({ selectInput("var","Date",choices = format(Sys.time(),'%Y-%m-%d')) })并将其与纯 html 包含到 index.html 中:<pre id="date" class="shiny-html-output"></pre>使用 selectInput 这完全是多余的,但现在我可以为 html 部分创建自己的函数。