1

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

我一直在用我当前的代码使浏览器崩溃——我相信它与 rCharts 试图生成 polychart 有关系,变量尚不可用——我的自定义输入必须先加载。我已经尝试过使用反应部件和隔离输出以及其他东西——要么我做的不对,要么它的方式不对——无论哪种方式都不起作用。

我对闪亮的 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)})
4

0 回答 0