Last active
September 1, 2016 18:13
-
-
Save loiyumba/6fa11d537eb1b2991e09ced36748ca82 to your computer and use it in GitHub Desktop.
Hospital ranking shiny app for 2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
setwd("..\\shiny_app\\Nat_Hos_Ranking\\hospital_ranking") | |
# Read the data | |
hosp_ranking <- read.csv("cleaned_data3.csv", stringsAsFactors = FALSE) | |
hosp_ranking$Name <- enc2native(hosp_ranking$Name) | |
hosp_ranking$Address <- enc2native(hosp_ranking$Address) | |
hosp_ranking$Telephone <- enc2native(hosp_ranking$Telephone) | |
hosp_ranking$Specialty <- enc2native(hosp_ranking$Specialty) | |
# Define UI for application | |
ui <- fluidPage(theme = "united.css", | |
# Application title | |
titlePanel("National Hospital Ranking by Speciality- Top 20"), | |
# Sidebar inputs | |
sidebarLayout( | |
sidebarPanel( | |
radioButtons("select", | |
"Select Speciality", | |
unique(hosp_ranking$Specialty) | |
), | |
submitButton("Submit"), | |
br(), | |
p("Note:"), | |
p("This data is based on Times of India report 'All India Critical Care Hospital Ranking Survey 2016' | |
published on 29th Jan 2016 and 'All India Lifestyle Hospital & Clinic Ranking Survey 2016' published | |
on 31st Aug 2016"), | |
hr(), | |
p("The raw data is available on this github", a("repo", href = "https://github.com/loiyumba/Dataset/tree/master/Hospital_Ranking", target = "_blank")), | |
p("The R code to generate same web app is available", a("here", href = "https://gist.github.com/loiyumba/6fa11d537eb1b2991e09ced36748ca82", target = "_blank")) | |
), | |
# Output table | |
mainPanel( | |
DT::dataTableOutput("table") | |
) | |
) | |
) | |
# Define server logic required to display dataframe | |
server <- function(input, output) { | |
output$table <- DT::renderDataTable(DT::datatable({ | |
hosp_ranking <- hosp_ranking[hosp_ranking$Specialty == input$select, ] | |
hosp_ranking <- hosp_ranking[, c("Rank", "Name", "Address", "Telephone")] | |
hosp_ranking}, | |
rownames = FALSE, class = 'cell-border stripe', | |
options = list(searching = FALSE, paging = FALSE))) | |
} | |
# Run the application | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment