Story
In the pandemic, the countries all over world have suffered a very tough peroid and taken different measures to slow the spread of the covid-19.
Google also provides a data which indicate how does the pandemic affected people moving. This is the story I want to share with you.
By insight the data provided by Google, we can see these effects on the people moving trends from six different areas, they are: retail and recreation, grocery and pharmarcy, parks, transit stations, workplaces, and residential activity.
You can use your mouse to explor the deatil data and pick up any country you intestred in from the dropdown list on the left side.
Code
Server.R
library(readr)
library(shiny)
library(dplyr)
library(plotly)
library(rapportools)
GMR <- read_csv("Global_Mobility_Report.csv")
GMR_Country <- GMR %>% filter(is.na(GMR$sub_region_1) & is.na(GMR$sub_region_2))
GMR_Country <- GMR_Country %>% select(-(sub_region_1:sub_region_2))
colnames(GMR_Country) <- c("code", "country","date","retail_recreation", "grocery_pharmacy","parks","transit", "workplace","residential")
# server.R
shinyServer(function(input, output){
contrylist <- unique(GMR_Country$country)
output$countryChoice <- renderUI(selectInput("country", "Select a country:",
choices=contrylist, selected="Australia"))
output$linePlot <- renderPlotly({
filtered <- GMR_Country
{
if(is.empty(input$country)){
filtered <- filter(GMR_Country, country == "Australia")
}
else{
filtered <- filter(GMR_Country, country == input$country)
}
}
plot_ly(data=filtered, x = ~filtered$date) %>%
add_lines(y = ~filtered$retail_recreation,name="Retail & Recreation") %>%
add_lines(y = ~filtered$grocery_pharmacy, name = "Grocery & Pharmacy") %>%
add_lines(y = ~filtered$parks, name = "Parks") %>%
add_lines(y = ~filtered$transit, name = "Transit Stations") %>%
add_lines(y = ~filtered$workplace, name = "Workplace") %>%
add_lines(y = ~filtered$residential, name = "Residential") %>%
layout(title = "Mobility Changed", xaxis = list(title = "date"), yaxis = list(title = "mobility changed", ticksuffix = "%", range=c(-100,100)))
})
})
UI.R
library(shiny)
library(plotly)
shinyUI(fluidPage(
titlePanel("How does the panamic change people mobility"),
fluidRow(
column(12,
h6("Pick up country in the drop-down list bellow to get more detail information by country"),
h6(""),
uiOutput("countryChoice")
),
column(12,
mainPanel(width = 12,
h4("Use your mouse to explore the data!"),
h4(""),
h6("Data from: Google LLC Google COVID-19 Community Mobility Reports. https://www.google.com/covid19/mobility/ Accessed: <14/06/2020>"),
h1(""),
plotlyOutput("linePlot")
)
)
)
))
Data Reference