ggplot(comunas) +
geom_sf()
ggplot(comunas) +
geom_sf(aes(fill = comunas))
dim(mortalidad2024)
## [1] 15 2
str(mortalidad2024)
## 'data.frame': 15 obs. of 2 variables:
## $ comuna: int 1 2 3 4 5 6 7 8 9 10 ...
## $ tasa : num 3.4 0 6 7 5.5 7.5 5.2 8.9 4 5.6 ...
summary(mortalidad2024)
## comuna tasa
## Min. : 1.0 Min. :0.000
## 1st Qu.: 4.5 1st Qu.:3.200
## Median : 8.0 Median :5.500
## Mean : 8.0 Mean :4.833
## 3rd Qu.:11.5 3rd Qu.:6.300
## Max. :15.0 Max. :8.900
names(mortalidad2024)
## [1] "comuna" "tasa"
ggplot(mortalidad2024) +
geom_col(aes(x = factor(comuna), y = tasa))
library(sf)
comunas <- st_read('https://bitsandbricks.github.io/data/CABA_comunas.geojson')
## Reading layer `CABA_comunas' from data source
## `https://bitsandbricks.github.io/data/CABA_comunas.geojson'
## using driver `GeoJSON'
## Simple feature collection with 15 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -58.53152 ymin: -34.70529 xmax: -58.33514 ymax: -34.52754
## Geodetic CRS: WGS 84
dim(comunas)
## [1] 15 5
names(comunas)
## [1] "barrios" "perimetro" "area" "comunas" "geometry"
head(comunas)
## Simple feature collection with 6 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -58.4627 ymin: -34.6625 xmax: -58.33514 ymax: -34.56935
## Geodetic CRS: WGS 84
## barrios
## 1 CONSTITUCION - MONSERRAT - PUERTO MADERO - RETIRO - SAN NICOLAS - SAN TELMO
## 2 RECOLETA
## 3 BALVANERA - SAN CRISTOBAL
## 4 BARRACAS - BOCA - NUEVA POMPEYA - PARQUE PATRICIOS
## 5 ALMAGRO - BOEDO
## 6 CABALLITO
## perimetro area comunas geometry
## 1 35572.65 17802807 1 MULTIPOLYGON (((-58.36854 -...
## 2 21246.61 6140873 2 MULTIPOLYGON (((-58.39521 -...
## 3 10486.26 6385991 3 MULTIPOLYGON (((-58.41192 -...
## 4 36277.44 21701236 4 MULTIPOLYGON (((-58.3552 -3...
## 5 12323.47 6660526 5 MULTIPOLYGON (((-58.41287 -...
## 6 10990.96 6851029 6 MULTIPOLYGON (((-58.43061 -...
ggplot(comunas) +
geom_sf()
ggplot(comunas) +
geom_sf(aes(fill = comunas))
rivadavia <- st_read('https://bitsandbricks.github.io/data/avenida_rivadavia.geojson')
## Reading layer `avenida_rivadavia' from data source
## `https://bitsandbricks.github.io/data/avenida_rivadavia.geojson'
## using driver `GeoJSON'
## Simple feature collection with 1 feature and 1 field
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: -58.53014 ymin: -34.63946 xmax: -58.37017 ymax: -34.60711
## Geodetic CRS: WGS 84
ggplot(comunas) +
geom_sf(aes(fill = comunas)) +
geom_sf(data = rivadavia, color = "red")
nueva_columna <- c("Sur", "Norte", "Sur", "Sur", "Sur", "Norte", "Sur", "Sur",
"Sur", "Norte", "Norte", "Norte", "Norte", "Norte", "Norte")
comunas <- mutate(comunas, ubicacion = nueva_columna)
head(comunas)
## Simple feature collection with 6 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -58.4627 ymin: -34.6625 xmax: -58.33514 ymax: -34.56935
## Geodetic CRS: WGS 84
## barrios
## 1 CONSTITUCION - MONSERRAT - PUERTO MADERO - RETIRO - SAN NICOLAS - SAN TELMO
## 2 RECOLETA
## 3 BALVANERA - SAN CRISTOBAL
## 4 BARRACAS - BOCA - NUEVA POMPEYA - PARQUE PATRICIOS
## 5 ALMAGRO - BOEDO
## 6 CABALLITO
## perimetro area comunas geometry ubicacion
## 1 35572.65 17802807 1 MULTIPOLYGON (((-58.36854 -... Sur
## 2 21246.61 6140873 2 MULTIPOLYGON (((-58.39521 -... Norte
## 3 10486.26 6385991 3 MULTIPOLYGON (((-58.41192 -... Sur
## 4 36277.44 21701236 4 MULTIPOLYGON (((-58.3552 -3... Sur
## 5 12323.47 6660526 5 MULTIPOLYGON (((-58.41287 -... Sur
## 6 10990.96 6851029 6 MULTIPOLYGON (((-58.43061 -... Norte
ggplot(comunas) +
geom_sf(aes(fill = ubicacion)) +
geom_sf(data = rivadavia, color = "red")
mortalidad2024 <- mutate(mortalidad2024, ubicación = nueva_columna)
head(mortalidad2024)
## comuna tasa ubicación
## 1 1 3.4 Sur
## 2 2 0.0 Norte
## 3 3 6.0 Sur
## 4 4 7.0 Sur
## 5 5 5.5 Sur
## 6 6 7.5 Norte
```