Guest User

Untitled

a guest
Nov 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. output$bar3 <- renderPlotly({
  2.  
  3. s <- CT_Data2 %>% filter(Sector == input$Sector & Airline == input$Airline1)
  4. d <- group_by(s, Booking.Month, Agency.Group)
  5. f <- summarize(d,num1 = sum(Bookings), num2 = sum(Pax))
  6. l = dcast(f, Booking.Month ~ Agency.Group, value.var= "num1")
  7. print(l)
  8. print(str(l))
  9. colNames <- names(l)[-1]
  10. print(colNames)
  11.  
  12. p <- plotly::plot_ly()
  13. for(trace in colNames)
  14. {
  15. p <- p %>% plotly::add_trace(data = l,x = ~Booking.Month, y = ~trace, name = trace)
  16.  
  17. }
  18. p %>% layout(title = "Trend Over Time",
  19. xaxis = list(title = ""),
  20. yaxis = list (title = "Value"),type='bar')
  21.  
  22. })
  23.  
  24. 'data.frame': 5 obs. of 3 variables:
  25. $ Booking.Month: chr "Aug" "Jul" "Jun" "Oct" ...
  26. $ Cleartrip : num NA NA NA 10 NA
  27. $ ROM : num 32 31 21 25 20
  28.  
  29. Booking.Month Cleartrip ROM
  30. 1 Aug NA 32
  31. 2 Jul NA 31
  32. 3 Jun NA 21
  33. 4 Oct 10 25
  34. 5 Sep NA 20
Add Comment
Please, Sign In to add comment