Advertisement
Guest User

r shiny

a guest
Jan 11th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. library(shiny)
  2. library(RMySQL)
  3.  
  4. # Define UI for application that draws a histogram
  5. ui <- fluidPage(
  6.  
  7. # Give the page a title
  8. titlePanel("Channel Plot"),
  9.  
  10. # Generate a row with a sidebar
  11. sidebarLayout(
  12.  
  13. # Define the sidebar with one input
  14. sidebarPanel(
  15. selectInput("Channel", "Channel Selector:",
  16. choices=rownames(dataChannel)),
  17. hr(),
  18. helpText("Select the channel you want to show.")
  19. ),
  20.  
  21. # Create a spot for the barplot
  22. mainPanel(
  23. plotOutput("Channelplot")
  24. )
  25.  
  26. )
  27.  
  28. )
  29.  
  30. # Define a server for the Shiny app
  31. server <- function(input, output) {
  32. mydb = dbConnect(MySQL(), user='pxleai1q_1501057', password='zo4dbCfsqcI7', dbname='pxleai1q_1501057', host='pxl-ea-ict.be')
  33.  
  34. dbListFields(mydb, 'ssFinal')
  35.  
  36. #rsID = dbSendQuery(mydb, "select id from ssFinal")
  37. #dataID = fetch(rsID, n=-1)
  38. rsMAC = dbSendQuery(mydb, "select MAC from ssFinal")
  39. dataMAC = fetch(rsMAC, n=-1)
  40. rsRSSI = dbSendQuery(mydb, "select RSSI from ssFinal")
  41. dataRSSI = fetch(rsRSSI, n=-1)
  42. rsChannel = dbSendQuery(mydb, "select Channel from ssFinal")
  43. dataChannel = fetch(rsChannel, n=-1)
  44. rsInlog = dbSendQuery(mydb, "select Inlog from ssFinal")
  45. dataInlog = fetch(rsInlog, n=-1)
  46. rsLastseen = dbSendQuery(mydb, "select Lastseen from ssFinal")
  47. dataLastseen = fetch(rsLastseen, n=-1)
  48.  
  49. dataMAC
  50. dataRSSI
  51. dataChannel
  52. dataInlog
  53. dataLastseen
  54.  
  55. #df <- data.frame(dfMAC = c(dataMAC), dfRSSI = c(dataRSSI), dfInlog = c(dataInlog), dfChannel = c(dataChannel))
  56. #df
  57. #
  58. #MAC <- df$MAC
  59. #INLOG <- df$Inlog
  60. #RSSI <- df$RSSI
  61. #CHANNEL <- df$Channel
  62.  
  63. # Fill in the spot we created for a plot
  64. output$Channelplot <- renderPlot({
  65.  
  66. # Render a barplot
  67. barplot(WorldPhones[,input$Channel]*1000,
  68. main=input$Channel,
  69. ylab="Channel",
  70. xlab="Number of connections")
  71. })
  72. }
  73.  
  74. # Run the application
  75. shinyApp(ui = ui, server = server)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement