[英]R shiny: how to make an operation based on textInput
I would like to check if a textInput has been completed, and then run an operation based on this. 我想检查textInput是否已完成,然后根据此操作运行。 For some reason, the following simplified code does not work. 出于某种原因,以下简化代码不起作用。 Is there something wrong ? 有什么不对 ?
library(shiny)
ui <- pageWithSidebar(
headerPanel("TEST"),
sidebarPanel(
textInput('C1', "","C1")
),
mainPanel(uiOutput("value"))
)
server <- function(input,output){
output$value <- renderUI({
#input$C1
if (is.null(input$C1)){
value <- 0}
else{
value <- 1
}
})
}
runApp(list(ui=ui,server=server))
Any suggestion highly appreciated. 任何建议都高度赞赏。
Cheers 干杯
The code inside renderUI must return a "tags" object, that is, a valid html. renderUI中的代码必须返回“tags”对象,即有效的html。 your code returns 0 or 1, neither of which is a valid return value in that context. 您的代码返回0或1,这两个都不是该上下文中的有效返回值。 all you need is to enclose the return value in something that creates such code, for example, instead of 您只需要将返回值包含在创建此类代码的内容中,例如,而不是
value<-0
try 尝试
h4("0")
and everything will be fine. 一切都会好的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.