R 闪亮的拉丝数据集功能不工作

R 闪亮的拉丝数据集功能不工作,r,shiny,R,Shiny,server.ui shinyServer( function(input, output) { plot <- eventReactive(input$button, { if (input$gtype == "Time to Change") { dataset = subset(TDU, LBTEST == input$study, drop=FALSE) ggplot(dataset, aes_string(x= 'VISITNUM', y = 'LBBLC

server.ui

shinyServer(

function(input, output) {

plot <- eventReactive(input$button, {

if (input$gtype == "Time to Change") {

    dataset = subset(TDU, LBTEST == input$study, drop=FALSE)
    ggplot(dataset, aes_string(x= 'VISITNUM', y = 'LBBLCHGR' , col='factor(ARMAN)')) + 
      geom_line(data = dataset, aes_string(x='VISITNUM',y = 'LBBLCHGR' ,group='SUBJID')) +


    }

    else {

    dataset = subset(TDU, LBTEST == input$study, drop=FALSE)
    ggplot(dataset, aes_string(x = 'ARMCD', y = 'LBBLCHGR', col='factor(VISITNUM)')) + geom_line()

    }

output$plot <- renderPlot({
  plot() 

})

output$brush_info <- renderPrint({
  brushedPoints(dataset, input$plot_brush)
})

})

})
简单地说,如何访问数据帧或嵌入在循环中的任何对象

编辑:

我想出了一个解决办法

data = reactive({

    dataset = subset(TDU, LBTEST == input$study, drop=FALSE)

}) 



output$brush_info <- renderPrint({
  brushedPoints(data(), input$plot_brush)
})
data=reactive({
数据集=子集(TDU,LBTEST==输入$study,drop=FALSE)
}) 

输出$brush\u信息您在这里谈论的是什么循环?此外,您仅在绘图的
eventReactive
内定义
dataset
。在
renderPrint
中无法看到该变量。也许您想要一个反应式数据对象?请参见“反应性表达式”下的示例,因此我必须将数据集放在反应性数据对象中,以使其可由renderPrint查看?您在这里谈论的是什么循环?此外,您仅在绘图的
eventReactive
内定义
dataset
。在
renderPrint
中无法看到该变量。也许您想要一个反应式数据对象?请参见“反应性表达式”下的示例,因此我必须将数据集放在反应性数据对象中,以使其可由renderPrint查看?
data = reactive({

    dataset = subset(TDU, LBTEST == input$study, drop=FALSE)

}) 



output$brush_info <- renderPrint({
  brushedPoints(data(), input$plot_brush)
})