R: In Shiny, how can I fix an inapplicable method for "xxtable" being applied to an object of class "reactive"

I am getting this error:

Error in UseMethod("xtable") : 
  no applicable method for 'xtable' applied to an object of class "reactive"

      

UI.R

library(shiny)
shinyUI(pageWithSidebar(
  headerPanel("Test App"),
  sidebarPanel(
    textInput(inputId="text1", 
              label = "Enter Keywords"),
    actionButton("goButton", label = "Go!", icon = "search")
  ),
  mainPanel(
    p('Your search:'),
    textOutput('text1'),
    p(''),
    textOutput('text3'),
    p('Search Results'),
    tableOutput('searchResult')
  )
))

      

Server.R

library(shiny)

data <- read.csv("./data/data.csv", quote = "")

shinyServer(
  function(input, output) {
    searchResult<- reactive({
      subset(asos, grepl(input$text1, asos$Title))
    })

    output$text1 <- renderText({input$text1})
    output$text3 <- renderText({      
      if (input$goButton == 0) "Get your search on!"
      else if (input$goButton == 1) "Computing... here what I found!"
      else "OK, I updated the results!"
    })
    output$searchResult <- renderTable({ 
      searchResult
    })
  }
)

      

+3


source to share


1 answer


reactive

returns a function. To call a reactive function, you will use:



output$searchResult <- renderTable({ 
  searchResult()
})

      

+9


source







All Articles