5

I am trying to add graph for the output which i have generated using shiny. I am getting error for graph generation. Can someone please have a look and assist. The bar graph parameters are calculation based outputs generated from calculations.

server
output$graph<- renderPlotly({

  plotly( x= c(as.numeric(input$contract), round(frateperton()), differencerate()),

         y= c('Contract Rate', 'ZBC Rate', 'Difference'),

         name = "Zero Based Rate Chart",

         type = "bar")

})


UI
plotlyOutput("graph"),

mayank14
  • 89
  • 1
  • 2
  • 6

1 Answers1

25

First of all, two remarks on your post :

  • it is not reproducible, see here to learn what a reproducible example is and how to make one
  • clearly you haven't searched enough. Typing "r shiny plotly output" in any search engine gives several potential solutions (here for example).

Next time you have a problem, please consider these two points before making a post on StackOverflow.

Now, here's the answer (using iris data since your example is not reproducible):

library(shiny)
library(plotly)

ui <- fluidPage(
  selectInput("choice", "Choose", choices = names(iris), selected = NULL),
  plotlyOutput("graph")
  )

server <- function(input, output, session){

  output$graph <- renderPlotly({
    plot_ly(iris, x = ~get(input$choice), y = ~Sepal.Length, type = 'scatter', mode = 'markers')
  })
}

shinyApp(ui, server)
bretauv
  • 4,789
  • 2
  • 14
  • 46