r光泽:隐藏和显示动词
我目前正在尝试创建一个带有多个标签面板的R Shiny应用程序。 在一个选项卡面板上,我想输入一些数字,然后根据按钮显示并隐藏输入的数字。 我使用shinyjs进行隐藏和动词,并获取数字,但是当我运行该应用程序时,在klick klick klick klick klick klick klick klick klick klick klick the Button上都不会发生。
有人知道如何解决这个问题吗?
这是我的代码的最低示例:
library(shiny)
library(shinyjs)
ui <- tagList(
useShinyjs(),
navbarPage(
"shinyjs with navbarPage",
tabPanel("tab1",
actionButton("button1", "Click me"),
div(id = "hello", "Hello!")),
tabPanel("tab2",
sidebarPanel(
textInput('str_values', 'Enter values in comma delimited format (e.g. 5.6, 6.7, 4.1, ...)', "")),
mainPanel(
actionButton("button2", "Click me"),
div(id = "div_values",verbatimTextOutput("oid_values")))
)))
server <- function(input, output, session) {
num_values <- reactive(as.numeric(unlist(strsplit(input$str_values,","))))
observeEvent(input$button1, {
toggle("hello")
})
observeEvent(input$button2, {
toggle("div_values")
output$oid_values <- renderPrint({
cat("your output:\n")
print(num_values())
})
})
}
shinyApp(ui, server)
I am currently trying to create an R Shiny app with multiple tab panels.
On one tab panel I would like to enter some numbers and then depending on a button show and hide the numbers entered.
I use shinyjs for the hiding and verbatimTextOutput to get the numbers but when I run the app nothing happens after klicking the button.
Does anyone know how to fix this?
Here is a minimum example of my code:
library(shiny)
library(shinyjs)
ui <- tagList(
useShinyjs(),
navbarPage(
"shinyjs with navbarPage",
tabPanel("tab1",
actionButton("button1", "Click me"),
div(id = "hello", "Hello!")),
tabPanel("tab2",
sidebarPanel(
textInput('str_values', 'Enter values in comma delimited format (e.g. 5.6, 6.7, 4.1, ...)', "")),
mainPanel(
actionButton("button2", "Click me"),
div(id = "div_values",verbatimTextOutput("oid_values")))
)))
server <- function(input, output, session) {
num_values <- reactive(as.numeric(unlist(strsplit(input$str_values,","))))
observeEvent(input$button1, {
toggle("hello")
})
observeEvent(input$button2, {
toggle("div_values")
output$oid_values <- renderPrint({
cat("your output:\n")
print(num_values())
})
})
}
shinyApp(ui, server)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论