HTMLUI(index.HTML)的动态输入
我想用html/css从头开始定制我闪亮的应用程序。因此,我使用index.html而不是ui.r,并遇到以下问题: 我在ui.r中使用动态输入,例如:HTMLUI(index.HTML)的动态输入,html,r,shiny,Html,R,Shiny,我想用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">
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>
日期
2015-08-10
{}
由于我必须使用Sys.time()而不是html代码中的实际日期,我很好奇在ui中仅使用.html时是否可以调用R/shinny?shinny有一个特殊的函数:
updateSelectInput
在ShinyUI中保留choices=NULL
或类似的choices=“请选择一些东西。”
(无论是通过ui.R还是index.html生成的)
然后在server.R内部,调用updateSelectInput
将选项
属性更改为反应式上下文中所需的任何属性
下面是一个单文件应用程序中的一些简单代码示例:
app <- shinyApp(
ui = shinyUI(fluidPage(
selectInput("inputID", label = "Reactive Select Input." , choices = "Please Select, Monsieur."),
actionButton("buttonID", label = "Refresh Select Options.")
)),
server = function(session, input, output) {
observeEvent(input$buttonID, {
updateSelectInput(session, "inputID", choices = as.character(Sys.time()))
})
}
)
appshinny为此有一个特殊功能:updateSelectInput
在ShinyUI中保留choices=NULL
或类似的choices=“请选择一些东西。”
(无论是通过ui.R还是index.html生成的)
然后在server.R内部,调用updateSelectInput
将选项
属性更改为反应式上下文中所需的任何属性
下面是一个单文件应用程序中的一些简单代码示例:
app <- shinyApp(
ui = shinyUI(fluidPage(
selectInput("inputID", label = "Reactive Select Input." , choices = "Please Select, Monsieur."),
actionButton("buttonID", label = "Refresh Select Options.")
)),
server = function(session, input, output) {
observeEvent(input$buttonID, {
updateSelectInput(session, "inputID", choices = as.character(Sys.time()))
})
}
)
app不使用selectInput
,您可以尝试在html文件中使用uiOutput
div,并从应用程序的server.R
部分添加selectInput
。请参见动态创建控件。。。第二部分非常感谢你的建议。因此,我可以在server.r中创建html输出,例如:output$date而不是使用selectInput
,您可以尝试在html文件中使用uiOutput
div,并从应用程序的server.r
部分添加selectInput
。请参见动态创建控件。。。第二部分非常感谢你的建议。因此,我可以在server.r中创建html输出,例如:output$date