具有X轴和Y轴选择输入的闪亮和rCharts / Polycharts

时间:2015-06-15 13:52:00

标签: r shiny rcharts polychart

我有一个问题,我导入一个大数据集,然后从该数据集生成一些选择输入,然后希望能够有一个图,我可以从数据中自由选择我的x轴和y轴组。

我一直在崩溃浏览器,使用我当前的代码 - 我相信rCharts试图生成多边形图,但变量尚不可用 - 我的自定义输入必须首先加载。我尝试过使用被动部件和隔离输出,以及其他东西 - 要么我做得不好,要么不正确 - 无论哪种方式都不起作用。

我对闪亮的R,特别是rCharts很新,但是我的图表只使用了一个输入 - 在尝试使多重选择时出现问题。

我有三个以下的UI,它们为renderCharts提供输入,我将在下面显示:

    output$TestSelection <- renderUI({
          selectInput("TestSel", "Test Variable", ls(df, pattern = ".*?_meas|.*?_calc"))
    })
    output$customx <- renderUI({
          selectInput("xcustom", "Custom Graph - X", ls(df), selected = input$TestSel) 
    }) 
    output$customy <- renderUI({
         selectInput("ycustom", "Custom Graph - Y", ls(df), selected = input$TestSel) 
    }) 

renderChart2代码:

   output$customplot <- renderChart2({
      if(is.null(input$xcustom)|is.null(input$ycustom))
        return(rCharts$new())

      #Removing all unneccessary data from dataframe,
      dataPlot <- df[,c("DUT", input$ycustom, input$xcustom)]

      custom_chart <- rPlot(x = input$xcustom,y = input$ycustom,
                            data = dataPlot, 
                            type = "point", 
                            tooltip = "#!function(item){return item.DUT}!#", 
                            sample = FALSE)

      #Adjusting width to fit the current screen
      custom_chart$set(width = session$clientData$output_plot2_width , title = paste(input$ycustom, " vs. ", input$ycustom, sep =""))

      #Setting the correct axis
      axisincrease = abs((max(dataPlot[,input$xcustom])-min(dataPlot[,input$xcustom]))*0.05)

      custom_chart$guides(
       x = list(
          min = pretty(dataPlot[,input$xcustom])[1]-axisincrease,
          max = tail(pretty(dataPlot[,input$xcustom]),1)+axisincrease,
          numticks = length(dataPlot[,input$xcustom])
        ),
       y = list(
          min = pretty( dataPlot[, input$ycustom] ) [1],
          max = tail( pretty( dataPlot[, input$ycustom] ), 1 )
       )
       )
       return(custom_chart)})

0 个答案:

没有答案