【问题标题】:R Shiny GGplot reactive graph not workingR Shiny GGplot反应图不起作用
【发布时间】:2017-11-17 18:32:21
【问题描述】:

我正在尝试在 R Shiny 中创建散点图,其中用户从反应性 combodf1() 的列中选择 X 和 Y,该反应性是由其他反应性构建的。如果您将输入设置为xy 并直接将列名设置为有效,但是从input$metric_a 等设置它们(您可以看到选项的名称和combodf1() 的列相同) ,数据不存在。非常感谢这里的任何帮助!

 Part of the UI:
          selectInput("metric_a", "metric_a:",
                      c("Buzz" = "buzz",
                        "Aided" = "aided",
                        "Adaware" = "adaware")),

          selectInput("metric_b", label = ("Metric B"), 
                  c("Buzz" = "buzz",
                    "Aided" = "aided",
                    "Adaware" = "adaware")),


Part of the server:

       combotest<- reactive({do.call(cbind, list(adaware()$Value, buzz()$Value, aided()$Value))})
      combodf<- reactive({as.data.frame(combotest())})
      # Renaming reactive cols - WORKS, PLYR function
      combodf1<-reactive({rename(combodf(), c("V1"="adaware", "V2"='buzz', 'V3' = 'aided'))})

      # PLOT 

      output$plot2<-renderPlot({
        ggplot(data=combodf1(),aes(x=input$metric_a,y=input$metric_b))+geom_point(colour='red')})

      }

【问题讨论】:

    标签: r ggplot2 shiny


    【解决方案1】:

    找到解决方案,你必须使用:

    当您的xyinput$GGPlot 中的变量时,aes_string 而不是aes

    希望这可以节省一些时间!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      • 2015-07-20
      • 2021-08-04
      • 2020-06-26
      相关资源
      最近更新 更多