10/05/2020
TRABAJO PRACTICO N°3
CIENCIA DE DATOS PARA CIUDADES II: Descargando y analizando datos de redes sociales
Snyders, Federico / Vargas, Juan
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.0 ✓ purrr 0.3.4
## ✓ tibble 3.0.1 ✓ dplyr 0.8.5
## ✓ tidyr 1.0.3 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(osmdata)
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(leaflet)
library(rtweet)
##
## Attaching package: 'rtweet'
## The following object is masked from 'package:purrr':
##
## flatten
twitter_token <- create_token(
app = "UrbanaTweets",
consumer_key = "ZHR5NrUO3WaPrRhYOQaQ2Y31W",
consumer_secret = "ym7M6Iy2euHw9ptQ8OpsK4CKiftuKHjhUt5Cbt3T2fUKvw1vuJ",
access_token = "1257472379095302152-CLsbhnqKyYbBKO6ix4PnUFxG5Hmpnw",
access_secret = "fZt2EQu4iptDqJnoMZD1Vd1lwZHT8HwjHUTzR5wEZzkWy")
#Buscamos los tweets en un radio de 20 millas del estadio Stinky Socks Hockey of BOSTON
hockey_BOSTON <- search_tweets(q = "hockey",
geocode = "42.338795,-71.093804,20mi",
include_rts = FALSE,
n = 10000,
retryonratelimit = TRUE)
users_data(hockey_BOSTON) %>% head()
## # A tibble: 6 x 20
## user_id screen_name name location description url protected followers_count
## <chr> <chr> <chr> <chr> <chr> <chr> <lgl> <int>
## 1 104633… JamieGatli… Jami… Boston,… "Covering … <NA> FALSE 1128
## 2 628633… quig87 R. Q… Boston,… "" <NA> FALSE 43
## 3 622422… drdougbost… doug Boston,… "M.D. & fo… <NA> FALSE 1411
## 4 622422… drdougbost… doug Boston,… "M.D. & fo… <NA> FALSE 1411
## 5 644542… CantonComm… Cant… Canton,… "Local TV … http… FALSE 777
## 6 644542… CantonComm… Cant… Canton,… "Local TV … http… FALSE 777
## # … with 12 more variables: friends_count <int>, listed_count <int>,
## # statuses_count <int>, favourites_count <int>, account_created_at <dttm>,
## # verified <lgl>, profile_url <chr>, profile_expanded_url <chr>,
## # account_lang <lgl>, profile_banner_url <chr>, profile_background_url <chr>,
## # profile_image_url <chr>
#Los 5 usuarios con mas seguidores.
hockey_BOSTON %>%
top_n(5, followers_count) %>%
arrange(desc(followers_count)) %>%
select(screen_name, followers_count, location, text)
## # A tibble: 7 x 4
## screen_name followers_count location text
## <chr> <int> <chr> <chr>
## 1 NHLBruins 1521416 Boston, … "If you missed #WhenHockeyRuledTheHub, …
## 2 NHLBruins 1521416 Boston, … "“It got to the point where they put st…
## 3 BostonGlobe 776219 Boston, … "MIAA basketball, hockey committees add…
## 4 BostonGlobe 776219 Boston, … "Inside the 'NASA of hockey.’ A look be…
## 5 BostonGlobe 776219 Boston, … "A first-timer’s first impressions of c…
## 6 BostonGlobe 776219 Boston, … "The NH legislature is the third larges…
## 7 BostonGlobe 776219 Boston, … "Jack Dugan, NCAA hockey scoring leader…
ggplot(filter(hockey_BOSTON, !is_retweet))+
geom_histogram(aes(x = retweet_count))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
hockey_BOSTON %>%
filter(!is_retweet) %>%
filter(retweet_count == max(retweet_count)) %>%
select(screen_name, retweet_count, followers_count, location, text)
## # A tibble: 1 x 5
## screen_name retweet_count followers_count location text
## <chr> <int> <int> <chr> <chr>
## 1 TheBostonPr… 97 16850 Boston, … "Recreating iconic hocke…
#Frecuencia de los tweets por hora
ts_plot(hockey_BOSTON, "hours")+
theme_minimal()+
labs(title= "Frecuencia de tweets por hora",
subtitle = "Menciones de la palabra ´HOCKEY´ en Boston",
caption = "Fuente: twitter",
x = "horas",
y = "cantidad")
#Procedencia de los usuarios de Boston y cercanias
hockey_BOSTON %>%
filter(location != "", !is.na(location)) %>%
count(location) %>%
top_n(20, n) %>%
ggplot() +
geom_col(aes(x = reorder(location, n), y = n)) +
coord_flip() +
labs(title = "Procedencia de los usuarios",
subtitle = "Boston y cercanías",
x = "ubicación",
y = "cantidad",
caption= "Fuente: twitter")+
theme_minimal()
hockey_BOSTON2 <- lat_lng(hockey_BOSTON)
hockey_BOSTON2 <- hockey_BOSTON2 %>%
select(-geo_coords, -coords_coords, -bbox_coords)
hockey_BOSTON_GEO <- hockey_BOSTON2 %>%
filter(!is.na(lat), !is.na(lng))
nrow(hockey_BOSTON_GEO)
## [1] 40
#Creamos un box con logitudes y latitudes
bbox_tweets <- make_bbox(lon = hockey_BOSTON_GEO$lng, lat = hockey_BOSTON_GEO$lat)
bbox_tweets
## left bottom right top
## -71.46667 42.05995 -70.78484 42.52675
#Lo descargamos los datos usando un zoom de x11 y después lo graficamos
mapa_tweets <- get_stamenmap(bbox_tweets, zoom = 11)
## Source : http://tile.stamen.com/terrain/11/617/756.png
## Source : http://tile.stamen.com/terrain/11/618/756.png
## Source : http://tile.stamen.com/terrain/11/619/756.png
## Source : http://tile.stamen.com/terrain/11/620/756.png
## Source : http://tile.stamen.com/terrain/11/621/756.png
## Source : http://tile.stamen.com/terrain/11/617/757.png
## Source : http://tile.stamen.com/terrain/11/618/757.png
## Source : http://tile.stamen.com/terrain/11/619/757.png
## Source : http://tile.stamen.com/terrain/11/620/757.png
## Source : http://tile.stamen.com/terrain/11/621/757.png
## Source : http://tile.stamen.com/terrain/11/617/758.png
## Source : http://tile.stamen.com/terrain/11/618/758.png
## Source : http://tile.stamen.com/terrain/11/619/758.png
## Source : http://tile.stamen.com/terrain/11/620/758.png
## Source : http://tile.stamen.com/terrain/11/621/758.png
## Source : http://tile.stamen.com/terrain/11/617/759.png
## Source : http://tile.stamen.com/terrain/11/618/759.png
## Source : http://tile.stamen.com/terrain/11/619/759.png
## Source : http://tile.stamen.com/terrain/11/620/759.png
## Source : http://tile.stamen.com/terrain/11/621/759.png
ggmap(mapa_tweets)
#Ahora usamos Toner Lite como interface de statemap
hockey_BOSTON_line<- get_stamenmap(bbox_tweets, maptype = "terrain-lines", zoom = 11)
## Source : http://tile.stamen.com/terrain-lines/11/617/756.png
## Source : http://tile.stamen.com/terrain-lines/11/618/756.png
## Source : http://tile.stamen.com/terrain-lines/11/619/756.png
## Source : http://tile.stamen.com/terrain-lines/11/620/756.png
## Source : http://tile.stamen.com/terrain-lines/11/621/756.png
## Source : http://tile.stamen.com/terrain-lines/11/617/757.png
## Source : http://tile.stamen.com/terrain-lines/11/618/757.png
## Source : http://tile.stamen.com/terrain-lines/11/619/757.png
## Source : http://tile.stamen.com/terrain-lines/11/620/757.png
## Source : http://tile.stamen.com/terrain-lines/11/621/757.png
## Source : http://tile.stamen.com/terrain-lines/11/617/758.png
## Source : http://tile.stamen.com/terrain-lines/11/618/758.png
## Source : http://tile.stamen.com/terrain-lines/11/619/758.png
## Source : http://tile.stamen.com/terrain-lines/11/620/758.png
## Source : http://tile.stamen.com/terrain-lines/11/621/758.png
## Source : http://tile.stamen.com/terrain-lines/11/617/759.png
## Source : http://tile.stamen.com/terrain-lines/11/618/759.png
## Source : http://tile.stamen.com/terrain-lines/11/619/759.png
## Source : http://tile.stamen.com/terrain-lines/11/620/759.png
## Source : http://tile.stamen.com/terrain-lines/11/621/759.png
hockey_BOSTON_TL <- get_stamenmap(bbox_tweets, maptype = "toner-lite", zoom = 11)
## Source : http://tile.stamen.com/toner-lite/11/617/756.png
## Source : http://tile.stamen.com/toner-lite/11/618/756.png
## Source : http://tile.stamen.com/toner-lite/11/619/756.png
## Source : http://tile.stamen.com/toner-lite/11/620/756.png
## Source : http://tile.stamen.com/toner-lite/11/621/756.png
## Source : http://tile.stamen.com/toner-lite/11/617/757.png
## Source : http://tile.stamen.com/toner-lite/11/618/757.png
## Source : http://tile.stamen.com/toner-lite/11/619/757.png
## Source : http://tile.stamen.com/toner-lite/11/620/757.png
## Source : http://tile.stamen.com/toner-lite/11/621/757.png
## Source : http://tile.stamen.com/toner-lite/11/617/758.png
## Source : http://tile.stamen.com/toner-lite/11/618/758.png
## Source : http://tile.stamen.com/toner-lite/11/619/758.png
## Source : http://tile.stamen.com/toner-lite/11/620/758.png
## Source : http://tile.stamen.com/toner-lite/11/621/758.png
## Source : http://tile.stamen.com/toner-lite/11/617/759.png
## Source : http://tile.stamen.com/toner-lite/11/618/759.png
## Source : http://tile.stamen.com/toner-lite/11/619/759.png
## Source : http://tile.stamen.com/toner-lite/11/620/759.png
## Source : http://tile.stamen.com/toner-lite/11/621/759.png
ggmap(hockey_BOSTON_TL) +
geom_point(data = hockey_BOSTON_GEO, aes(x = lng, y = lat))+
labs(title = "Tweets que mencionan la palabra HOCKEY",
subtitle = "Boston y cercanías",
x = "longitud",
y = "latitud",
caption= "Fuente: twitter")
ggmap(hockey_BOSTON_line) +
geom_point(data = hockey_BOSTON_GEO,
aes(x = lng, y = lat, color = followers_count)) +
scale_color_distiller(palette = "Spectral")
#Mostramos con mayor claridad los usuarios con mas seguidores
hockey_BOSTON_Ag <- arrange(hockey_BOSTON_GEO, followers_count)
ggmap(hockey_BOSTON_TL) +
geom_point(data = hockey_BOSTON_Ag,
aes(x = lng, y = lat, color = followers_count)) +
scale_color_distiller(palette = "Spectral")
#Tambien observamos tweets más retwitteados
ggmap(hockey_BOSTON_TL) +
geom_point(data = hockey_BOSTON_Ag,
aes(x = lng, y = lat, color = followers_count, size = retweet_count),
alpha = .5) +
scale_color_distiller(palette = "Spectral")
#Cremos un mapa interactivo para mostrar la informacion de TWITTER
paleta <- colorNumeric(
palette = "viridis",
domain = hockey_BOSTON_Ag$followers_count)
leaflet(hockey_BOSTON_Ag) %>%
addTiles() %>%
addCircleMarkers(popup = ~text,
color = ~paleta(followers_count)) %>%
addLegend(title = "seguidores", pal = paleta, values = ~followers_count)
## Assuming "lng" and "lat" are longitude and latitude, respectively
16/05/2020
TRABAJO PRACTICO N°4
CIENCIA DE DATOS PARA CIUDADES II: Analizando datos espaciotemporales
Snyders, Federico / Vargas, Juan
library(tidyverse)
library(ggmap)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:dplyr':
##
## intersect, setdiff, union
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
#Continuamos trabajando con los datos de la ciudad de Boston
#Descargamos el dataset de Public Works Violations desde la pagina de datos de Boston. https://data.boston.gov/dataset/705244a6-70a6-4ff8-ab8e-56441aff18e7/resource/800a2663-1d6a-46e7-9356-bedb70f5332c/download/tmpn8xjjv3f.csv
VEP_BOSTON <- read.csv("/cloud/project/tmpn8xjjv3f.csv")
summary(VEP_BOSTON)
## ticket_no status_dttm status
## HVIOL-213782: 14 2014-10-20 12:41:33: 14 Closed:13059
## HVIOL-260240: 12 2015-09-24 16:53:13: 12 Open : 5905
## HVIOL-288018: 12 2016-03-04 14:19:15: 12
## HVIOL-213583: 10 2014-10-16 14:44:02: 10
## HVIOL-220337: 10 2014-12-22 16:31:47: 10
## HVIOL-244290: 10 2015-06-18 16:59:29: 10
## (Other) :18896 (Other) :18896
## code value
## 105.1 : 2785 N/A:18964
## 116.2 : 2311
## CMR410.500 : 1455
## CMR410.351 A: 1004
## CMR410.550 B: 702
## CMR410.482 A: 639
## (Other) :10068
## description
## Unsafe and Dangerous :3182
## Failure to Obtain Permit :2785
## Owners Responsibility to Maintain Structural Elements - Structural elements shall be maintained free from holes, cracks, loose plaster, or other defects. :1455
## Owners Installation/Maintenance Responsibility - All facilities and equipment which are required by owner including but not limited to water, gas, electrical and heating, shall be installed in accordance with all accepted codes. :1004
## Maintenance : 869
## Extermination of Insects, Rodents and Skunks - The owner of a dwelling containing two or more dwelling units shall maintain it and its premises free from all rodents, cockroaches and insect infestation and shall be responsible for exterminating them: 702
## (Other) :8967
## stno sthigh street suffix
## 9 : 292 :14612 Washington : 422 ST :13576
## 7 : 258 : 1038 Blue Hill : 368 AVE : 2644
## 8 : 255 29 : 42 Commonwealth: 213 RD : 1261
## 11 : 250 12 : 37 Centre : 186 CT : 189
## 12 : 249 20 : 37 Chelsea : 171 St : 161
## 16 : 248 8 : 37 Beacon : 169 : 143
## (Other):17412 (Other): 3161 (Other) :17435 (Other): 990
## city state zip sam_id latitude
## Dorchester :6100 MA:18964 Min. :2108 Min. : 22 Min. :42.23
## Boston :2323 1st Qu.:2121 1st Qu.: 59692 1st Qu.:42.30
## Roxbury :2105 Median :2125 Median :112830 Median :42.32
## East Boston :1769 Mean :2126 Mean :131124 Mean :42.32
## Mattapan :1064 3rd Qu.:2128 3rd Qu.:170415 3rd Qu.:42.35
## South Boston: 970 Max. :2467 Max. :439722 Max. :42.39
## (Other) :4633 NA's :8
## longitude location
## Min. :-71.18 (42.3532559998174, -71.1283960015975): 32
## 1st Qu.:-71.10 (42.2986200002182, -71.0799900014532): 27
## Median :-71.08 (42.2807199998246, -71.0906500008474): 26
## Mean :-71.08 (42.3727969999766, -71.0381640012413): 24
## 3rd Qu.:-71.06 (42.3105399999765, -71.0611500012388): 22
## Max. :-71.00 (42.3097560000641, -71.0830180016258): 21
## (Other) :18812
#Observamos que la mayoria de las faltas en obras publicas se encuentran sobre la calle Washington
#Convertimos fecha (date)
VEP_BOSTON <- VEP_BOSTON %>% mutate(fecha = ymd_hms(status_dttm))
## Warning: 2 failed to parse.
#Mostramos los registros de violaciones de Obras Públicas de la ciudad de Boston para el año 2019
VEP_BOSTON %>%
filter(year(fecha) == 2019) %>%
ggplot() +
geom_bar(aes(x = month(fecha, label = TRUE)))+
labs(title = "Violaciones de Obras Públicas en BOSTON",
subtitle = "año 2019",
fill = "Cantidad",
caption= "Fuente: https://data.boston.gov/dataset", y="Cantidad",
x="MES")
#Analizamos en profundidamos las 2 faltas mas cometidas.
VEP_BOSTON %>%
count(description) %>%
top_n(2) %>%
arrange(desc(n))
## Selecting by n
## # A tibble: 2 x 2
## description n
## <fct> <int>
## 1 Unsafe and Dangerous 3182
## 2 Failure to Obtain Permit 2785
#Las 2 faltas mas cometidas corresponden a “edificos inseguros y peligrosos” y edificios con “falta de permiso”
#Guardamos los 2
VEP_BOSTON_FRECUENTES <- VEP_BOSTON %>%
count(description) %>%
top_n(2) %>%
pull(description)
## Selecting by n
VEP_BOSTON %>%
filter(year(fecha) == 2019,
description %in% VEP_BOSTON_FRECUENTES) %>%
ggplot() +
geom_bar(aes(x = month(fecha, label = TRUE), fill = description))+
labs(title = "Violaciones de Obras Públicas en BOSTON",
subtitle = "Faltas cometidas año 2019",
fill = "Cantidad",
caption= "Fuente: https://data.boston.gov/dataset", y="Cantidad",
x="MES")
#Mostramos las 2 dos faltas mas cometidas a lo largo del año 2019
conteo <- VEP_BOSTON %>%
filter(year(fecha) == 2019,
description %in% VEP_BOSTON_FRECUENTES) %>%
count(description, mes = month(fecha, label = TRUE))
ggplot(conteo) +
geom_line(aes(x = mes, y = n, group = description, color = description))+
labs(title = "Violaciones de Obras Públicas en BOSTON",
subtitle = "Faltas cometidas año 2019",
fill = "Cantidad",
caption= "Fuente: https://data.boston.gov/dataset", y="Cantidad",
x="MES")
#Observamos que para la variable de edificio inseguro y peligroso el mes julio se registraron la mayor cantidad de observaciones, mientras que para los edificios sin permisos.
#Mostramos los faltas cometidas por dia de la semana para el año 2019.
conteo2 <- VEP_BOSTON %>%
filter(year(fecha) == 2019,
description %in% VEP_BOSTON_FRECUENTES) %>%
count(description, diasemana = wday (fecha, label = TRUE))
ggplot(conteo2) +
geom_line(aes(x = diasemana, y = n, group = description, color = description))+
labs(title = "Violaciones de Obras Públicas en BOSTON",
subtitle = "Faltas por dia de semana",
fill = "Cantidad",
caption= "Fuente: https://data.boston.gov/dataset", y="Cantidad",
x="DIA")
#Mostramos la información usando porcentajes
conteo2 <- conteo2 %>%
group_by(description) %>%
mutate(pct = n / sum(n) * 100)
ggplot(conteo2) +
geom_line(aes(x = diasemana, y = pct, group = description, color = description))+
expand_limits(y = 0)+
labs(title = "Violaciones de Obras Públicas en BOSTON",
subtitle = "Faltas por dia de semana",
fill = "Cantidad",
caption= "Fuente: https://data.boston.gov/dataset", y="Cantidad",
x="DIA")
#MAPAS: filtramos las observaciones que no tienen coordenadas para obtener la “bounding box” de nuestros datos para hacer el mapa.
coordenadas <- function(campo_coordenadas) {
extraer_coordenadas <- function(lista_coords) {
data_frame(lonitude = lista_coords[1],
latitude = lista_coords[2])
}
map_df(campo_coordenadas, extraer_coordenadas)
}
VEP_BOSTON <- VEP_BOSTON %>%
filter(!is.na(longitude), !is.na(latitude))
bbox <- make_bbox(VEP_BOSTON$longitude, VEP_BOSTON$latitude)
MAPA_BASE <- get_stamenmap(bbox = bbox, maptype = "toner-lite", zoom = 11)
#Mapa base de la ciudad de boston en “toner-lite”
ggmap(MAPA_BASE)
#El mapa de densidad muestra la mayor concentracion de las faltas cometidas en edificios públicos durante el año 2019 en la ciudad de Boston.
ggmap(MAPA_BASE) +
geom_bin2d(data = VEP_BOSTON, aes(x = longitude, y = latitude), bins = 100) +
scale_fill_viridis_c()+
labs(title = "Densidad de faltas",
subtitle = "BOSTON 2019",
x = "Longitud",
y = "Latitud",
fill = "Cantidad",
caption = "FUENTE: https://data.boston.gov/dataset")
#El mapa muestra las distribuciones espaciales para las faltas cometidas en edificios públicos.
ggmap(MAPA_BASE) +
geom_density2d(data = VEP_BOSTON, aes(x = longitude, y = latitude, color = stat(level))) +
scale_color_viridis_c()+
labs(title = "Distribucion espacial de la densidad de faltas",
subtitle = "BOSTON 2019",
x = "Longitud",
y = "Latitud",
fill = "Cantidad",
caption = "FUENTE: https://data.boston.gov/dataset")
#El siguiente mapa muestra la distribución de las dos faltas analizadas en los gráficos de lineas.
ggmap(MAPA_BASE) +
geom_point(data = filter(VEP_BOSTON, description %in% VEP_BOSTON_FRECUENTES),
aes(x = longitude, y = latitude, color = description),
size = 1, alpha = 0.5) +
guides(color = guide_legend(override.aes = list(size=2, alpha = 1))) +
scale_color_brewer(palette = "Set1")+
labs(title = "Violaciones de Obras Públicas ",
subtitle = "Boston Año 2019",
x = "Longitud",
y = "Latitud",
fill = "Cantidad",
caption = "FUENTE: https://data.boston.gov/dataset")
#MAPAS FACETADOS
#El siguiente mapa muestra la distribución espacial de las faltas para las dos variables analizadas en los gráficos de lineas.
ggmap(MAPA_BASE) +
geom_density2d(data = filter(VEP_BOSTON, description %in% VEP_BOSTON_FRECUENTES), aes(x = longitude, y = latitude, color = stat(level))) +
scale_color_viridis_c() +
facet_wrap(~description)+
labs(title = "Distribucion espacial de la densidad de faltas",
subtitle = "BOSTON 2019",
x = "Longitud",
y = "Latitud",
fill = "Cantidad",
caption = "FUENTE: https://data.boston.gov/dataset")
#El siguiente mapa facetado muestra la distrución de cada una de las variables.
ggmap(MAPA_BASE) +
geom_point(data = filter(VEP_BOSTON, description %in% VEP_BOSTON_FRECUENTES),
aes(x = longitude, y = latitude, color = description),
size = 1, alpha = 0.5) +
scale_color_brewer(palette = "Set1") +
facet_wrap(~description)+
labs(title = "Violaciones de Obras Públicas ",
subtitle = "Boston Año 2019",
x = "Longitud",
y = "Latitud",
fill = "Cantidad",
caption = "FUENTE: https://data.boston.gov/dataset")
#COMBINACION DE TIEMPO Y ESPACIO
#El siguiente mapa facetado muestra las observaciones para los edificios inseguros y peligrosos por cada dia de la semana
VEP_BOSTON <- VEP_BOSTON %>%
mutate(dia_semana = wday(fecha, label = TRUE)) %>%
filter(!is.na(dia_semana))
ggmap(MAPA_BASE) +
geom_point(data = filter(VEP_BOSTON,
description == "Unsafe and Dangerous"),
aes(x = longitude, y = latitude, color = description), alpha = .7, size = .4) +
facet_wrap(~dia_semana, nrow = 2)+
labs(title = "Violaciones de Obras Públicas ",
subtitle = "Boston Año 2019",
x = "Longitud",
y = "Latitud",
fill = "Cantidad",
caption = "FUENTE: https://data.boston.gov/dataset")
#El siguiente mapa muestra la concentración espacial durante los dias de la semana para las variables faltante de persmiso de obra.
ggmap(MAPA_BASE) +
geom_density2d(data = filter(VEP_BOSTON, description == "Failure to Obtain Permit"),
aes(x = longitude, y = latitude, color=stat(level))) +
scale_color_viridis_c() +
facet_wrap(~dia_semana, nrow = 2)+
labs(title = "Distribucion espacial de la densidad de faltas",
subtitle = "BOSTON 2019",
x = "Longitud",
y = "Latitud",
fill = "Cantidad",
caption = "FUENTE: https://data.boston.gov/dataset")
## Warning: Computation failed in `stat_density2d()`:
## missing value where TRUE/FALSE needed