我正在尝试编写一个简单的应用程序,以便从twitter api获取推文,并将它们显示在闪亮的表格中。 最后,我也想存储它们,但我还没完成......
这是我的代码, 代码:
library(twitteR)
library (shiny)
ui = fluidPage(
fluidRow(
column(4, textInput("searchkw", label = "search:", value = "#movie")),
column(8, tableOutput('table'))
)
)
server = function(input, output) {
# OAuth authentication
consumer_key <- ("XXX")
consumer_secret <- ("XXX")
access_token <- ("XXX")
access_secret<-("XXX")
options(httr_oauth_cache = TRUE) # enable using a local file to cache OAuth access credentials between R sessions
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
# Issue search query to Twitter
dataInput <- reactive({
data <- twListToDF(searchTwitter(input$searchkw, n = 10),
data$created <- as.character(data$created)
)})
# Create a reactive table
data$table <- renderTable(
dataInput()[, c("text", "screenName")]
)
}
shinyApp(ui = ui, server = server)
但是我收到了错误:
“数据$ table&lt; - renderTable(dataInput()[,c(”text“,”screenName“)])中的错误: 'closure'类型的对象不是子集“
这里的任何人都可以帮我解决这个问题吗? 非常感谢。 :)