#importar datos y librerias
library(pacman)
p_load("base64enc", "htmltools", "mime", "xfun", "prettydoc", "readr", "knitr", "DT", "tidyverse", "scales", "gridExtra", "modeest", "fdth")
dataSonora <- read_csv("sonora.csv")## Parsed with column specification:
## cols(
## country_region_code = col_character(),
## country_region = col_character(),
## sub_region_1 = col_character(),
## sub_region_2 = col_logical(),
## metro_area = col_logical(),
## iso_3166_2_code = col_character(),
## census_fips_code = col_logical(),
## date = col_character(),
## retail_and_recreation_percent_change_from_baseline = col_double(),
## grocery_and_pharmacy_percent_change_from_baseline = col_double(),
## parks_percent_change_from_baseline = col_double(),
## transit_stations_percent_change_from_baseline = col_double(),
## workplaces_percent_change_from_baseline = col_double(),
## residential_percent_change_from_baseline = col_double()
## )
* creación del data frame
#hasta octubre
FechaMR <- seq(from = as.Date("2020-02-15"), to = as.Date("2020-10-13"), by='day')
#data frame
Retail_Recreation_Percentage <- dataSonora$retail_and_recreation_percent_change_from_baseline
Grocery_Pharmacy_Percentage <- dataSonora$grocery_and_pharmacy_percent_change_from_baseline
Parks_Percentage <- dataSonora$parks_percent_change_from_baseline
TransitStations_Percentage <- dataSonora$transit_stations_percent_change_from_baseline
Workplaces_Percentage <- dataSonora$workplaces_percent_change_from_baseline
Residential_Percentage <- dataSonora$residential_percent_change_from_baseline
#graficas
porcentaje_RR <- dataSonora$retail_and_recreation_percent_change_from_baseline
porcentaje_GP <- dataSonora$grocery_and_pharmacy_percent_change_from_baseline
porcentaje_PP <- dataSonora$parks_percent_change_from_baseline
porcentaje_TS <- dataSonora$transit_stations_percent_change_from_baseline
porcentaje_WP <- dataSonora$workplaces_percent_change_from_baseline
porcentaje_RP <- dataSonora$residential_percent_change_from_baseline
dataMR <- data.frame(x=FechaMR, y=Retail_Recreation_Percentage)Gráficas
gRR1 <- ggplot(data=dataMR) + geom_line(aes(x=FechaMR, y=porcentaje_RR), size=1, colour="purple") + geom_hline(yintercept = 0) +
theme_light() +
xlab("Fecha") +
ylab("Porcentaje") +
ggtitle("a) Comercio y recreación (-45%)")
gGP2 <- ggplot(data=dataMR) + geom_line(aes(x=FechaMR, y=porcentaje_GP), size=1, colour="brown") + geom_hline(yintercept = 0) +
theme_light() +
xlab("Fecha") +
ylab("Porcentaje") +
ggtitle("b) Farmacias y abarrotes (-11%)")
gPP3 <- ggplot(data=dataMR) + geom_line(aes(x=FechaMR, y=porcentaje_PP), size=1, colour="blue") +
geom_hline(yintercept = 0) +
theme_light() +
xlab("Fecha") +
ylab("Porcentaje") +
ggtitle("c) Parques (-37%)")
gTS4 <- ggplot(data=dataMR) +
geom_line(aes(x=FechaMR, y=porcentaje_TS), size=1, colour="green") +
geom_hline(yintercept = 0) +
theme_light() +
xlab("Fecha") +
ylab("Porcentaje") +
ggtitle("d) Estaciones de tránsito (-43%)")
gWP5 <- ggplot(data=dataMR) +
geom_line(aes(x=FechaMR, y=porcentaje_WP), size=1, colour="red") +
geom_hline(yintercept = 0) +
theme_light() +
xlab("Fecha") +
ylab("Porcentaje") +
ggtitle("e) Espacios de trabajo (-37%)")
gRP6 <- ggplot(data=dataMR) +
geom_line(aes(x=FechaMR, y=porcentaje_RP), size=1, colour="black") +
geom_hline(yintercept = 0) +
theme_light() +
xlab("Fecha") +
ylab("Porcentaje") +
ggtitle("f) Hogares (+18%)")
p_load(gridExtra)
grid.arrange(gRR1, gGP2, gPP3, gTS4, gWP5, gRP6)Análisis de movilidad local para Sonora utilizando datos de google mobility report
- eventos del 3 de enero al 6 de febrero del 2020.- fueron 4 los dias festivos en suceder, el 5 de febrero cayo el Dia de la Constitucion, lo cual causo que durante ese dia o dias cercanos las personas estuvieran afuera de sus casa.
El 16 de septiembre que fue el Dia de la independencia se puede observar por la grafica e) que muchas personas tuvieron libre ese dia, esto hizo que se aumentara el valor de la poblacion en los parques tanto en los hogares, esta ultima no incrementando tanto por lo que muestra la grafica f).
- Inicio del invierno y finalización del verano.- comparando el inicio del verano del 2019 con el inicio en 2020 se tienen estas fechas. -21 de junio para 2019 - hasta el 22 de septiembre -20 de junio para 2020 - hasta el 22 de septiembre con esto nos damos cuenta que no hay una gran diferencia de fechas.