Skip to content

Commit

Permalink
# Added Choice for different "concern" scores
Browse files Browse the repository at this point in the history
  • Loading branch information
lboullu committed Apr 28, 2020
1 parent fe60d14 commit cb6cf72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 10 additions & 6 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ server <- function(input, output, session) {
observeEvent({
input$CountryChoice
input$MapRegionChoice
input$ConcernChoice
},{

country_list <- input$CountryChoice
Expand Down Expand Up @@ -327,6 +328,9 @@ server <- function(input, output, session) {
}


concern_switch <-
switch(input$ConcernChoice, "1"="himself", "2"="family", "3"="friends", "4"="country", "5"="othercountries")

# Sending plots to ui ----

output$PlotlyGender100<-renderPlotly({ ggplotly(pGender100, tooltip = "text") })
Expand All @@ -338,7 +342,7 @@ server <- function(input, output, session) {
output$PlotlyStressMap <- renderPlotly({ggplotly(stress_map(world="world"), tooltip="text")} )
output$PlotlyIsolationMap<-renderPlotly({ggplotly(isolation_map(world="world"), tooltip="text")})
output$PlotlyTrustMap <- renderPlotly({ggplotly(trust_map(world="world"), tooltip="text")} )
output$PlotlyCoronaConcernMap<-renderPlotly({ggplotly(concern_map(world="world"), tooltip="text")})
output$PlotlyCoronaConcernMap<-renderPlotly({ggplotly(concern_map(world="world", who=concern_switch), tooltip="text")})
},
"2" = { #2 Africa
output$PlotlyStressMap <- renderPlotly({ ggplotly(stress_map(), tooltip="text") %>%
Expand All @@ -347,7 +351,7 @@ server <- function(input, output, session) {
layout(xaxis=list(range = c(-25,60)),yaxis=list(range = c(-40,40))) })
output$PlotlyTrustMap <- renderPlotly({ggplotly(trust_map(), tooltip="text") %>%
layout(xaxis=list(range = c(-25,60)),yaxis=list(range = c(-40,40))) })
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(), tooltip="text") %>%
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(who=concern_switch), tooltip="text") %>%
layout(xaxis=list(range = c(-25,60)),yaxis=list(range = c(-40,40))) })
},
"3" = { #3 America
Expand All @@ -357,7 +361,7 @@ server <- function(input, output, session) {
layout(xaxis=list(range = c(-180,-20)),yaxis=list(range = c(-60,80))) })
output$PlotlyTrustMap <- renderPlotly({ggplotly(trust_map(), tooltip="text") %>%
layout(xaxis=list(range = c(-180,-20)),yaxis=list(range = c(-60,80))) })
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(), tooltip="text") %>%
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(who=concern_switch), tooltip="text") %>%
layout(xaxis=list(range = c(-180,-20)),yaxis=list(range = c(-60,80))) })
},
"4" = { #4 Asia
Expand All @@ -367,7 +371,7 @@ server <- function(input, output, session) {
layout(xaxis=list(range = c(25,191)),yaxis=list(range = c(-15,90))) })
output$PlotlyTrustMap <- renderPlotly({ggplotly(trust_map(), tooltip="text") %>%
layout(xaxis=list(range = c(25,191)),yaxis=list(range = c(-15,90))) })
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(), tooltip="text") %>%
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(who=concern_switch), tooltip="text") %>%
layout(xaxis=list(range = c(25,191)),yaxis=list(range = c(-15,90))) })
},
"5" = { #5 Europe
Expand All @@ -377,7 +381,7 @@ server <- function(input, output, session) {
layout(xaxis=list(range = c(-25,50)),yaxis=list(range = c(33,72))) })
output$PlotlyTrustMap <- renderPlotly({ggplotly(trust_map(), tooltip="text") %>%
layout(xaxis=list(range = c(-25,50)),yaxis=list(range = c(33,72))) })
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(), tooltip="text") %>%
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(who=concern_switch), tooltip="text") %>%
layout(xaxis=list(range = c(-25,50)),yaxis=list(range = c(33,72))) })
},
"6" = { #Oceania
Expand All @@ -387,7 +391,7 @@ server <- function(input, output, session) {
layout(xaxis=list(range = c(100,300)),yaxis=list(range = c(-80,80))) })
output$PlotlyTrustMap <- renderPlotly({ggplotly(trust_map(world="world2"), tooltip="text") %>%
layout(xaxis=list(range = c(100,300)),yaxis=list(range = c(-80,80))) })
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(world="world2"), tooltip="text") %>%
output$PlotlyCoronaConcernMap <- renderPlotly({ggplotly(concern_map(world="world2", who=concern_switch), tooltip="text") %>%
layout(xaxis=list(range = c(100,300)),yaxis=list(range = c(-80,80))) })
}
)
Expand Down
4 changes: 4 additions & 0 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ ui <- fluidPage(
selectInput('MapRegionChoice', h3("Select Region"),
choices = list("World" = 1, "Africa" = 2, "Asia" = 3,
"America" = 4, "Europe" = 5, "Oceania" = 6),
selected = 1),
selectInput('ConcernChoice', h3("Concern for who?"),
choices = list("Themself" = 1, "My family" = 2, "My friends" = 3,
"My country" = 4, "Other countries" = 5),
selected = 1)
),
mainPanel(
Expand Down

0 comments on commit cb6cf72

Please sign in to comment.