Shiny Server Demo
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) | |
shinyServer(function(input, output) { | |
#ds = read.csv("data.csv") | |
ds = local(get(load("C:/Users/S769346/Desktop/SAFETY DATA ANALYSIS/SAFETY DATA ANALYSIS/test/df.rData"))) | |
xn = as.POSIXct(ds$"Date.of.Occurence",format="%m/%d/%Y") | |
ds["year"] = as.numeric(format(xn,"%Y")) | |
ds["month"] = as.numeric(format(xn,"%m")) | |
dataset <- reactive(function() { | |
ds[which(ds$"year" == input$Year),] | |
}) | |
output$plot <- reactivePlot(function() { | |
db = dataset() | |
hist(as.numeric(db$"month"),breaks = "Sturges",col=c('blue','red','green'),labels=T) | |
if(input$select == "Flight.Phase") | |
{ | |
da = db[which(db[input$select] == "Take-off"),] | |
hist(as.numeric(da$"month"),breaks = "Sturges",col=c('blue','red','green'),labels=T) | |
} | |
}) | |
output$summary <- renderPrint({ | |
db = dataset() | |
summary(db[input$select]) | |
}) | |
}) | |
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) | |
#ds = read.csv("data.csv") | |
ds = local(get(load("C:/Users/S769346/Desktop/SAFETY DATA ANALYSIS/SAFETY DATA ANALYSIS/test/df.rData"))) | |
x = names(ds) | |
shinyUI(pageWithSidebar( | |
headerPanel("Shiny Server Demo"), | |
sidebarPanel( | |
sliderInput('Year', 'Year', min=2010, max=2012, | |
value=min(2010,2012), step=1, round=0), | |
selectInput('select', 'Select Criteria', c(x[3],x[9],x[10],x[11],x[12],x[26])) | |
), | |
mainPanel( | |
plotOutput('plot'), | |
verbatimTextOutput("summary") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment