Advertisement
Guest User

Untitled

a guest
Nov 8th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #Navigation
  2. rm(list=ls(all=TRUE))
  3. library(shiny)
  4. library(DBI)
  5. library(ggplot2)
  6.  
  7. conn <- dbConnect(drv = RMySQL::MySQL(),dbname = "world",host = "localhost",username = "root",password = "xxxx")
  8. rs <- dbSendQuery(conn = conn, 'select * from city')
  9. Data <-fetch(rs, n=-1)
  10.  
  11. # Define the overall UI
  12. ui<-fluidPage(
  13. sidebarLayout(
  14. sidebarPanel(
  15. conditionalPanel(
  16. 'input.dataset === "Data"',
  17. checkboxGroupInput('show_vars', p(style = "font-family:Arial Black", "Select columns:"),
  18. names(Data), selected = names(Data))
  19. ),
  20. # Create a new Row in the UI for selectInputs
  21. fluidRow(p(style = "font-family:Arial Black", "Select rows:")
  22. ),
  23. fluidRow(
  24. column(6,
  25. selectInput("nam",
  26. "Name:",
  27. c("All",
  28. unique(as.character(Data$Name))))
  29. )),
  30. fluidRow(
  31. column(6,
  32. selectInput("cc",
  33. "CountryCode:",
  34. c("All",
  35. unique(as.character(Data$CountryCode))))
  36. )
  37. )
  38. ),
  39.  
  40. mainPanel(
  41. tabsetPanel(
  42. id = 'dataset',
  43. tabPanel('Data', DT::dataTableOutput('mytable1'))
  44. )
  45. )
  46. )
  47. )
  48. #server
  49. server<-function(input, output) {
  50.  
  51. # choose columns to display
  52. output$mytable1 <- DT::renderDataTable({
  53. DT::datatable(Data[, input$show_vars, drop = FALSE])
  54. })
  55. }
  56. shinyApp(ui, server)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement