服务器出现问题。R:无法正确使用actionButton中的observeEvent

服务器出现问题。R:无法正确使用actionButton中的observeEvent,r,shiny,action-button,R,Shiny,Action Button,我对shiny应用程序比较陌生,正在尝试制作一个简单的应用程序:虽然我能够正确运行ui.R,但我在服务器上遇到了问题。R……我想要的是在这个数字将用作arg后获取滑块条的值。对于函数wbpg,从下拉菜单中选择绘图类型,并在按下“运行”操作按钮时绘制相应变量…..当名为wbpgx的函数(其中x是滑块的值)时,所有结果和绘图都会保存….当wbpgx运行时,它会返回绘图此下拉菜单中包含所有绘图的列表 #UI.R shinyUI( fluidPage( titlePanel(title=h4("Te

我对shiny应用程序比较陌生,正在尝试制作一个简单的应用程序:虽然我能够正确运行ui.R,但我在服务器上遇到了问题。R……我想要的是在这个数字将用作arg后获取滑块条的值。对于函数wbpg,从下拉菜单中选择绘图类型,并在按下“运行”操作按钮时绘制相应变量…..当名为wbpgx的函数(其中x是滑块的值)时,所有结果和绘图都会保存….当wbpgx运行时,它会返回绘图此下拉菜单中包含所有绘图的列表

#UI.R
shinyUI( fluidPage(
  titlePanel(title=h4("Text Mining on  thread",align="centre")),

sidebarLayout(
    sidebarPanel(
  sliderInput("post","1. Choose no. of posts you want to run the model",value = 1, min = 1, max = 30000),
  br(),
  selectInput("plotvar","2. Select the variable you want to plot",choices=c("raw_dat"=1,"content"=2,"barplot"=3,"genderplot"=4,"girlplot"=5,"rawplot"=6,"adjplot"=7,
           "drinkplot"=8,"damageplot"=9,"songplot"=10,"sentimentplot"=11)),
  br(),
  actionButton(inputId="act",label = "RUN!")

  ),

  mainPanel(
    textOutput("out"),
    #tableOutput("tab"),
    plotOutput("hist1")
  )
)
))
这是服务器文件,存在以下问题:

#server.R
shinyServer(function(input, output) {
    #observeEvent(input$action,wbpage(as.numeric(input$post)))
    #output$data<-renderPrint({str(get(content))})
  observeEvent(input$act,{wbpg(np)})  

  output$out<-renderText(paste("No. of posts mined: ",input$post))

#defaul<-reactiveValues(data=wbpage(3000))
np<-wbpage(as.numeric(input$post))



output$hist1 <- renderPlot({barplot})

}) 
#output$hist1 <- 
    #renderPlot({
      #plots$barplot
    #output$tab<-
  #   renderTable({ 
  #  head(data())
    #})
  #output$hist2 <- renderPlot({
  #hist(rnorm(input$num))
  #raunchyplot
  #})
#}) 

在没有访问函数wbpg的情况下,让我尝试帮助您处理“observeEvent”调用返回的值。我认为您的问题是将“}”放在带有“observeEvent”的行上。单击“运行”按钮后希望发生的一切都需要在“}”范围内。如果这不是你需要的,请重申这个问题

在每次单击“运行”按钮时,使用以下代码查看返回的数据,以代替“observeEvent”命令。它显示滑块的值和下拉菜单中的数字

  observeEvent(input$act,{
    print (paste(input$post,input$plotvar,sep=' '))
  })

你的第一句评论是对的……这是一个错误,放错了地方。}谢谢你的回答。