-
-
Save sergiospagnuolo/c9fde498d827905f9ad91a5fef0bf4b3 to your computer and use it in GitHub Desktop.
Análise de dados de trânsito Bid/Waze https://www.iadb.org/en/topics-effectiveness-improving-lives/coronavirus-impact-dashboard
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(tidyverse) | |
library(clipr) | |
library(zoo) | |
bid %>% filter(region_type == "city") %>% distinct(region_slug) %>% count() | |
bid %>% filter(region_type == "city") %>% distinct(region_slug, population) %>% summarise(total = sum(population)) | |
# BRASIL | |
brasil <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "country" ) %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# BRASIL, apenas cidades | |
brasil_metro <- bid %>% | |
group_by(region_name, data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" ) %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# SAO PAULO, cidade | |
sao_paulo <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "São Paulo") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# SAO PAULO, UF | |
sp <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "state" & region_name == "Sao Paulo") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# RIO DE JANEIRO, cidade | |
rio_de_janeiro <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Rio de Janeiro") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# RIO DE JANEIRO, UF | |
rj <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "state" & region_name == "Rio De Janeiro") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Belo Horizonte, cidade | |
bh <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Belo Horizonte") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Recife, cidade | |
recife <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Recife") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Fortaleza, cidade | |
fortaleza <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Fortaleza") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Natal, cidade | |
natal <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Natal") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Brasília, cidade | |
salvador <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Salvador") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Goiania, cidade | |
goiania <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Goiânia") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Brasília, cidade | |
bsb <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Brasília") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Belém, cidade | |
belem <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Belém") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Brasília, cidade | |
manaus <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Manaus") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# São José dos Campos, cidade | |
sjc <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "São José dos Campos") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
# Curitiba, cidade | |
curitiba <- bid %>% | |
group_by(data, week_number) %>% | |
filter(week_number != 46 & region_type == "city" & region_name == "Curitiba") %>% | |
summarise(media = mean((ratio_20 - 1) * 100), mediana = median((ratio_20 - 1) * 100)) %>% | |
ggplot() + geom_bar(aes(data, media), stat = "identity", position = "dodge") | |
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(readr) | |
library(tidyverse) | |
# DADOS DE MOBILIDADE BID/WAZE | |
dia <- read_csv('http://tiny.cc/idb-traffic-daily') | |
semana <- read_csv('http://tiny.cc/idb-traffic-weekly') | |
metadata <- read_csv('http://tiny.cc/idb-traffic-metadata') | |
# agrega datas | |
bid$data <- as.Date(paste0(2020,"-", bid$max_month,"-", bid$max_day)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment