为什么反应功能在Shiny中不起作用?

时间:2016-06-14 17:21:04

标签: r shiny

我构建了一个Shiny App,它在带有用户输入的操作按钮上执行SQL,然后在几个“selectInput”选项中使用SQL结果来显示数据。但是,当我启动应用程序时,我遇到了关于“被动”结构的错误。

错误讯息:

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

Note: the specification for S3 class “AsIs” in package ‘jsonlite’ seems 
equivalent to one from package ‘DBI’: not turning on duplicate class 
definitions for this class.

Warning: Error in .getReactiveEnvironment()$currentContext: Operation not 
allowed without an active reactive context. (You tried to do something that 
can only be done from inside a reactive expression or observer.)
Stack trace (innermost first):

44: .getReactiveEnvironment()$currentContext
43: .dependents$register
42: data_sql.roi
41: unique
40: server [/srv/shiny-server/cls-Analyst-upload/server.R#104]
 1: runApp
Error in .getReactiveEnvironment()$currentContext() : 
Operation not allowed without an active reactive context. (You tried to do 
something that can only be done from inside a reactive expression or observer.)

server.r中的反应函数

    data_sql.roi <- eventReactive(input$goButton, {

    withProgress(message = 'SQL Querying', detail = 'Executing ... ', value = 0.99, {

              fetch(dbSendQuery(mydb_roi, 
                                  paste("select var1, 
                                                var2,
                                                var3,
                                                var4

                                         from data_table1
                                         where var1 = ",input$advertiser_id,"
                                         and var2 = ",input$attribution_window,"
                                         and var3 in (",input$study_type,")
                                         and date(var4) between ",input$dates[1]," and ",input$dates[2]"
                            ), n=-1)

          })
})  


data.roi <- data_sql.roi()

有谁知道为什么这个反应功能不起作用?

0 个答案:

没有答案