no of crashes per month donut plot added

This commit is contained in:
patrycjalazna 2021-06-23 16:05:52 +02:00
parent caa0588328
commit 10a467d608

View File

@ -77,7 +77,8 @@ ui <- fluidPage(
mainPanel(
# wykresiki
plotlyOutput("weekdayCrashes"),
plotlyOutput("hourCrashes")
plotlyOutput("hourCrashes"),
plotlyOutput("monthCrashes")
)
)
),
@ -174,8 +175,36 @@ server <- function(input, output, session) {
})
output$monthCrashes <- renderPlotly({
crashes_per_months <- airplane_crashes %>% count(Month)
crashes_per_months$Month <- as.character(crashes_per_months$Month)
crashes_per_months$Month[crashes_per_months$Month == 1] <- "January"
crashes_per_months$Month[crashes_per_months$Month == 2] <- "February"
crashes_per_months$Month[crashes_per_months$Month == 3] <- "March"
crashes_per_months$Month[crashes_per_months$Month == 4] <- "April"
crashes_per_months$Month[crashes_per_months$Month == 5] <- "May"
crashes_per_months$Month[crashes_per_months$Month == 6] <- "June"
crashes_per_months$Month[crashes_per_months$Month == 7] <- "July"
crashes_per_months$Month[crashes_per_months$Month == 8] <- "August"
crashes_per_months$Month[crashes_per_months$Month == 9] <- "September"
crashes_per_months$Month[crashes_per_months$Month == 10] <- "October"
crashes_per_months$Month[crashes_per_months$Month == 11] <- "November"
crashes_per_months$Month[crashes_per_months$Month == 12] <- "December"
df <- crashes_per_months
df <- df %>% arrange(match(Month, c("January", "February","March", "April", "May", "June", "July", "August", "September", "October", "November", "December")))
fig <- df %>% plot_ly(labels = ~Month, values = ~n, sort=FALSE)
fig <- fig %>% add_pie(hole = 0.4)
fig <- fig %>% layout(title = "No. of crashes per month", xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
fig
})
output$operatorCrashes <- renderStreamgraph({