[英]R: In Shiny how do I fix no applicable method for 'xtable' applied to an object of class “reactive”
I'm getting this error: 我收到这个错误:
Error in UseMethod("xtable") :
no applicable method for 'xtable' applied to an object of class "reactive"
UI.R 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 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's what I found!"
else "OK, I updated the results!"
})
output$searchResult <- renderTable({
searchResult
})
}
)
reactive
returns a function. reactive
返回一个函数。 To call the reactive function you would use: 要调用反应函数,您将使用:
output$searchResult <- renderTable({
searchResult()
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.