Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Navigation
- rm(list=ls(all=TRUE))
- library(shiny)
- library(DBI)
- library(ggplot2)
- conn <- dbConnect(drv = RMySQL::MySQL(),dbname = "world",host = "localhost",username = "root",password = "xxxx")
- rs <- dbSendQuery(conn = conn, 'select * from city')
- Data <-fetch(rs, n=-1)
- # Define the overall UI
- ui<-fluidPage(
- sidebarLayout(
- sidebarPanel(
- conditionalPanel(
- 'input.dataset === "Data"',
- checkboxGroupInput('show_vars', p(style = "font-family:Arial Black", "Select columns:"),
- names(Data), selected = names(Data))
- ),
- # Create a new Row in the UI for selectInputs
- fluidRow(p(style = "font-family:Arial Black", "Select rows:")
- ),
- fluidRow(
- column(6,
- selectInput("nam",
- "Name:",
- c("All",
- unique(as.character(Data$Name))))
- )),
- fluidRow(
- column(6,
- selectInput("cc",
- "CountryCode:",
- c("All",
- unique(as.character(Data$CountryCode))))
- )
- )
- ),
- mainPanel(
- tabsetPanel(
- id = 'dataset',
- tabPanel('Data', DT::dataTableOutput('mytable1'))
- )
- )
- )
- )
- #server
- server<-function(input, output) {
- # choose columns to display
- output$mytable1 <- DT::renderDataTable({
- DT::datatable(Data[, input$show_vars, drop = FALSE])
- })
- }
- shinyApp(ui, server)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement