Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205330

Error in [: object of type 'closure' is not subsettable when i use plotly

$
0
0

I am working on an app in shiny app o rstudio and i have a question in the second Tab of my app

You see the second tab of my app loads a data.frama written in the app.R file and prints it on rhandsome table, this tab has a selectinput that allows me to change between data.frames wich is some i was able todo thanks to reactivevalues functions and correspondly it does the same thing with the plots (wich i make with plotly) the problem is that i am trying to make the values change according to the selected data.frame and the selected

I have tried to do it by using the reactive function, like this

X.var<-reactive({
    output$varx <- renderUI({
      selectInput("variablex", "Seleccione la variable X", choices=names(TablaD()))
    })
  })

and

 Y.var<-reactive({
    output$vary <- renderUI({
      selectInput("variabley", "Seleccione la variable y", choices=names(TablaD()))
    })
  })

but when i use plotly like this

output$plot_three <-renderPlotly({
    plot_ly(data=I.Plot(), x = ~X.var(), y = ~Y.var(), name = 'High 2014', type = 'scatter', mode = 'lines',
            #x = ~Produccion_de_Energia_Neta, y = ~Produccion_de_Energia_Neta
            line = list(color = 'rgb(205, 12, 24)', width = 4)) %>%

      layout(title = "Grafico Lineal",
             xaxis = list(title = "Valores"),
             yaxis = list (title = "Kwh"))
  })

and run the app i get the following error

Warning: Error in [: object of type 'closure' is not subsettable
  104: recurse
  103: FUN
  102: lapply
  101: traceify
  100: plotly_build.plotly
   96: getFromNamespace("prepareWidget", "plotly")
   95: func
   82: origRenderFunc
   81: output$plot_three
    1: runApp

how should I introduce the variables x = ~X.var() and y = ~Y.var() so plotly can accept them and make the plot


Viewing all articles
Browse latest Browse all 205330

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>