首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发亮到RQDA查询

发亮到RQDA查询
EN

Stack Overflow用户
提问于 2019-07-22 17:05:02
回答 1查看 102关注 0票数 0

我试图在最近完成的一些定性数据分析的基础上创建一些动态输出。我需要用户做出一个选择,在闪闪发光。基于此,我需要使用SQLite在RQDA中运行一个查询。

我已经看过多个视频,关于重新激活输入的闪亮,但所有我试图应用的都没有发挥作用。我尝试使用SQLite ()和paste0()为我的查询创建一个文本块,但是using不允许我运行这个命令。

UI代码

代码语言:javascript
复制
library(shiny)
library(igraph)
library(sqldf)
library(RQDA)
library(DBI)
# Open the project
openProject("C:/SWOT Analysis/Qual Analysis of SWOTs.rqda")

# Get the table required for inputs
db <- dbConnect(SQLite(), dbname="Qual Analysis of SWOTs.rqda")

# Read in the inputs
codeCat <- dbReadTable(db, "codecat")[which(dbReadTable(db,"codecat")$status==1),c(3,1)]

# Set to a vector format for shiny
codeCat1 <- setNames(codeCat$catid, codeCat$name)

ui <- fluidPage(

  tabsetPanel(
    tabPanel(title = "2 Categories",
             tags$h1("Compare two coded categories"),
             wellPanel(selectInput(inputId = "Opt1", 
                                   label = "Select the first category",
                                   choices = codeCat1,
                                   selected = codeCat1[1]),

                       selectInput(inputId = "Opt2", 
                                   label = "Select the second category",
                                   choices = codeCat1,
                                   selected = codeCat1[2])),
             textOutput(outputId = "cat2"),
             plotOutput(outputId = "pcat2"),
             tableOutput(outputId = "tbl")


             )))

服务器码

代码语言:javascript
复制
server <- function(input, output, session){

  output$cat2 <- renderText({paste(input$Opt1, "and", input$Opt2, "have been selected.")})


a <- renderText({paste("SELECT codecat.name, freecode.name FROM codecat, freecode, treecode WHERE codecat.catid=treecode.catid AND freecode.id=treecode.cid AND treecode.status=1 and treecode.catid = ", input$Opt1, "or codecat.catid=treecode.catid AND freecode.id=treecode.cid AND 
treecode.status=1 and treecode.catid = ", input$Opt2)})


  # testing to see if the RQDA query works - this did
  output$tbl <-renderTable({RQDAQuery(paste("SELECT codecat.name, freecode.name FROM codecat, freecode, treecode WHERE codecat.catid=treecode.catid AND freecode.id=treecode.cid AND treecode.status=1 and treecode.catid = ", input$Opt1, "or codecat.catid=treecode.catid AND freecode.id=treecode.cid AND 
treecode.status=1 and treecode.catid = ", input$Opt2))})

# this will be used for plotting after doing clusters later
 # edges <- RQDAQuery(a())
  on.exit(DBI::dbDisconnect(db))
}

警告:.getReactiveEnvironment()$currentContext中的错误:不允许在没有活动反应上下文的情况下进行操作。(您试图做一些只能在反应性表达式或观察者中完成的事情。)这是我得到的错误信息-我知道我做了一些明显的错误,但我似乎看不到它!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-24 15:56:02

我已经找到了我自己的问题的答案,使用模块在闪亮-我最近发现这些链接到模块在R和重建的基础上,我的闪亮的应用程序,这一切似乎都运行良好。

模块化闪亮的应用程序 模块间通信

谢谢!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57150686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档