library(ggplot2)
library(dplyr)
library(gridExtra)
# Leer datos desde CSV
arbData <- read.table("censo_arboreo.csv", header=TRUE, sep=";", dec=".", stringsAsFactors=TRUE)
# Convertir columnas a numéricas
arbData$altura_arbol <- as.numeric(as.character(arbData$altura_arbol))
## Warning: NAs introduced by coercion
arbData$tallos <- as.numeric(as.character(arbData$tallos))
# Normalizar columna edad para evitar duplicados
arbData$edad <- factor(arbData$edad, levels=c("Juvenil", "Maduro", "Longevo"))
# Vista general
summary(arbData)
## ID2 id Barrio
## Min. : 1 0101G11264461: 1 Min. :101.0
## 1st Qu.: 1460 0101G12259648: 1 1st Qu.:101.0
## Median : 2919 0101G12259649: 1 Median :102.0
## Mean : 5581 0101G12259650: 1 Mean :139.1
## 3rd Qu.: 4378 0101G12259651: 1 3rd Qu.:199.0
## Max. :293606 0101G12259652: 1 Max. :199.0
## (Other) :5831
## barrio_nombre comuna Id_Arbol grupo
## Aguacatal :1827 Min. :1 Min. : 70768 G16 : 625
## Sector Patio Bonito: 448 1st Qu.:1 1st Qu.:255368 G23 : 534
## Terron Colorado :2699 Median :1 Median :261740 G22 : 527
## Vista Hermosa : 863 Mean :1 Mean :258334 G14 : 520
## 3rd Qu.:1 3rd Qu.:265376 G15 : 500
## Max. :1 Max. :271673 G21 : 455
## (Other):2676
## nombre_comun nombre_cientifico
## Limon swinglea, Swinglea: 743 Swinglea glutinosa : 743
## Leucaena : 431 Leucaena leucocephala: 431
## Palma areca : 358 Dypsis lutescens : 358
## Guacimo : 344 Guazuma ulmifolia : 344
## Carbonero : 217 Calliandra pittieri : 217
## Mango : 188 Mangifera indica : 188
## (Other) :3556 (Other) :3556
## union familia
## Swinglea glutinosa (Limon swinglea, Swinglea): 743 Fabaceae :1312
## Leucaena leucocephala (Leucaena) : 431 Rutaceae : 998
## Dypsis lutescens (Palma areca) : 358 Arecaceae : 767
## Guazuma ulmifolia (Guacimo) : 344 Malvaceae : 416
## Calliandra pittieri (Carbonero) : 217 Asparagaceae : 324
## Mangifera indica (Mango) : 188 Anacardiaceae: 209
## (Other) :3556 (Other) :1811
## vegetacion edad perimetro
## Arbol :3931 Juvenil: 579 N/A :5819
## Arbusto : 744 Maduro :4652 10.50 : 1
## Bambu : 18 Longevo: 606 11.00 : 1
## Palma : 850 12.77 : 1
## Planta arbustiva: 294 14.00 : 1
## 15.30 : 1
## (Other): 13
## cobertura confinamiento
## Cesped : 27 No:5036
## Cesped :4027 Si: 801
## Jardin : 1
## Jardin : 94
## Piso duro : 9
## Piso duro : 501
## Vegetacion Emergente:1178
## emplazamiento pb pap
## Anden :2350 0,6 : 121 0 :2849
## Parque Urbano :1142 0,7 : 115 0,3 : 61
## Escenario depor/cult :1068 0,8 : 113 0,2 : 59
## Rondas de rios : 832 0,3 : 110 0,4 : 58
## Rondas de canales : 167 0,4 : 106 0,25 : 50
## Separador Vial : 112 0,5 : 101 0,5 : 48
## (Other) : 166 (Other):5171 (Other):2712
## DAP DAP2 papdel papgrueso altura_fuste
## 0,06 : 392 0,06 : 392 0 :2988 0 :2988 2 : 754
## 0,07 : 373 0,07 : 373 0,1 : 148 0,2 : 140 3 : 575
## 0,04 : 312 0,04 : 312 0,2 : 132 0,3 : 95 4 : 385
## 0,11 : 312 0,11 : 312 0,12 : 122 0,22 : 85 1 : 329
## 0,05 : 304 0,05 : 304 0,15 : 114 0,4 : 76 2,5 : 253
## 0,08 : 293 0,08 : 293 0,13 : 105 0,25 : 75 1,5 : 222
## (Other):3851 (Other):3851 (Other):2228 (Other):2378 (Other):3319
## altura_arbol diferencia diametro_copa inclinacion
## Min. : 2.000 3 : 404 6 : 461 0 :4017
## 1st Qu.: 5.000 2 : 395 4 : 439 10 : 521
## Median : 7.000 4 : 345 3 : 429 15 : 359
## Mean : 7.355 1,5 : 271 2 : 419 20 : 204
## 3rd Qu.: 9.000 5 : 251 5 : 375 5 : 178
## Max. :23.000 2,5 : 215 8 : 275 25 : 146
## NA's :2853 (Other):3956 (Other):3439 (Other): 412
## orientacion otra_orientacion fuste
## Direccion de la via: 152 N/A :4828 Fuste Polifurcado:2849
## Hacia la casa : 144 zona verde: 256 Fuste Unico :2988
## Hacia la via : 475 parque : 197
## Ninguna :4035 rio : 147
## Otro :1031 Rio : 72
## Canal : 43
## (Other) : 294
## tallos raiz raiz_expuesta copa
## Min. : 1.000 Aerea : 7 No:4994 Irregular :3562
## 1st Qu.: 1.000 Subterranea : 42 Si: 843 Aparasolada :1173
## Median : 1.000 Subterranea :5788 Globosa : 782
## Mean : 2.214 Columnar : 192
## 3rd Qu.: 3.000 Conica : 45
## Max. :25.000 Ninguna : 41
## (Other) : 42
## densidad_copa vitalidad bacteriosis_tronco
## Alto (67 - 100%) : 13 Muerto : 115 Bacteriosis : 504
## Alto (67 - 100%) :2256 Regular : 35 N/A :5333
## Bajo (0 - 33%) : 20 Regular :4249
## Bajo (0 - 33%) :1255 Sano : 6
## Medio (34 - 66%) : 9 Sano :1431
## Medio (34 - 66%) :2284 Seco : 1
##
## fungosis_tronco insectos_tronco
## Fungosis : 888 Insectos :1316
## N/A :4949 N/A :4521
##
##
##
##
##
## ahorcamiento_tronco anillamiento_tronco
## Ahorcamiento : 90 Anillamiento : 22
## N/A :5747 N/A :5815
##
##
##
##
##
## golpes_tronco machetazos_tronco
## Golpes :1720 Machetazos :1388
## N/A :4117 N/A :4449
##
##
##
##
##
## presencia_metales_tronco
## N/A :5635
## Presencia de metales : 202
##
##
##
##
##
## acumulacion_escombros_tronco quemaduras_tronco
## Acumulacion de escombros : 113 N/A :5814
## N/A :5724 Quemaduras : 23
##
##
##
##
##
## pudricion_base_tronco huecos_tronco
## D. estructural base tronco: 208 Hueco : 49
## N/A :5629 N/A :5788
##
##
##
##
##
## alto_huecos_tronco ancho_huecos_tronco propundidad_huecos_tronco
## N/A :5788 N/A :5788 N/A :5788
## 0,1 : 10 0,4 : 4 0,1 : 9
## 0,04 : 8 0,1 : 3 0,03 : 7
## 0,05 : 4 0,15 : 3 0,12 : 5
## 0,13 : 3 0,9 : 3 0,05 : 4
## 0,2 : 3 0,06 : 2 0,2 : 3
## (Other): 21 (Other): 34 (Other): 21
## bacteriosis_follaje fungosis_follaje insectos_follaje
## Bacteriosis : 619 Fungosis : 155 Insectos :1428
## N/A :5218 N/A :5682 N/A :4409
##
##
##
##
##
## dasrramamiento_follaje golpes_follaje
## Desrramamiento :1855 Golpes : 313
## N/A :3982 N/A :5524
##
##
##
##
##
## mutilacion_follaje enrredos_follaje
## Mutilacion :1382 Enrredos : 78
## N/A :4455 N/A :5759
##
##
##
##
##
## parasitas_follaje quemaduras_follaje
## N/A :5339 N/A :5793
## Parasitas : 498 Quemaduras : 44
##
##
##
##
##
## estado_poda infraestructura_habitacional infraestructura_vial
## N/A : 42 N/A:5837 N/A:5837
## Poda No Tecnica:2813
## Poda Tecnica : 298
## Sin Podar :2684
##
##
##
## redes_de_servicio moviliario_urbano ninguna red_telefonica_sub
## N/A:5837 N/A:5837 N/A:5837 N/A:5837
##
##
##
##
##
##
## red_electrica_sub red_acueducto_sub red_gas_sub sin_identificar_sub
## N/A:5837 N/A :5726 N/A:5837 N/A:5837
## Red Acueducto : 111
##
##
##
##
##
## ninguna_cercania_sub dano_ondulacion
## N/A:5837 N/A :5582
## Ondulacion Terreno : 255
##
##
##
##
##
## dano_infraestructura ningun_dano
## Infraestructura : 34 N/A : 292
## N/A :5803 Ninguno :5545
##
##
##
##
##
## red_telefonica_air red_electrica_air sin_identificar_air
## N/A :5584 N/A :5621 N/A:5837
## Telecomuicaciones : 253 Red Electrica : 216
##
##
##
##
##
## ninguna_cercania_air contacto_horizontal contacto_inferior contacto_superios
## N/A:5837 Horizontal:3335 Inferior : 701 N/A :5204
## N/A :2502 N/A :5136 Superior : 633
##
##
##
##
##
## limpieza poda
## Limpieza :2071 N/A :2588
## N/A :3766 Poda :3249
##
##
##
##
##
## fertilizacion construir_crecamiento
## Fertilizacion :1955 Construir cerramiento : 6
## N/A :3882 N/A :5831
##
##
##
##
##
## eliminar_piso_duro eliminar_crecamiento
## Eliminacion Piso Duro : 131 Eliminar cerramiento : 42
## N/A :5706 N/A :5795
##
##
##
##
##
## transplante control_fitosanitario
## N/A :5833 Control Fitosanitario :2712
## Transplante : 4 N/A :3125
##
##
##
##
##
## ninguno2 erradicacion
## N/A :5786 Erradicacion : 460
## Ninguno : 51 N/A :5377
##
##
##
##
##
## Norte Este PLACA ACT_NOM_ESP OBSERVACION
## 873099,91: 3 1057986,39: 3 N/A:5837 N/A:5837 N/A:5837
## 873859,17: 3 1058728,98: 3
## 874152,39: 3 1058767,17: 3
## 873112,02: 2 1054426,4 : 2
## 873157,88: 2 1055315,79: 2
## 873164,75: 2 1055525,92: 2
## (Other) :5822 (Other) :5822
h1 <- ggplot(arbData, aes(x=altura_arbol)) +
geom_histogram(fill="blue", bins=30) +
labs(title="Histograma de Altura de Árboles", x="Altura (m)", y="Frecuencia")
h2 <- ggplot(arbData, aes(x=tallos)) +
geom_histogram(fill="red", bins=30) +
labs(title="Histograma de Número de Tallos", x="Número de tallos", y="Frecuencia")
h3 <- ggplot(arbData, aes(x=barrio_nombre, y=altura_arbol)) +
geom_boxplot(fill="lightblue") +
coord_flip() +
labs(title="Altura por Barrio", x="Barrio", y="Altura (m)")
h4 <- ggplot(arbData, aes(x=vegetacion, y=altura_arbol, fill=vegetacion)) +
geom_boxplot() +
labs(title="Altura por Tipo de Vegetación", x="Tipo de vegetación", y="Altura (m)")
grid.arrange(h1, h2, h3, h4, ncol=2)
## Warning: Removed 2853 rows containing non-finite outside the scale range
## (`stat_bin()`).
## Warning: Removed 2853 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Removed 2853 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
ggplot(arbData, aes(x=tallos, y=altura_arbol)) +
geom_jitter(alpha=0.5) +
geom_smooth(method="lm", colour="darkgreen") +
labs(title="Relación entre Altura y Número de Tallos", x="Número de tallos", y="Altura (m)")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 2853 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 2853 rows containing missing values or values outside the scale range
## (`geom_point()`).
cor(arbData$altura_arbol, arbData$tallos, use="complete.obs")
## [1] -0.1742662
ggplot(arbData, aes(x=edad, y=altura_arbol, fill=edad)) +
geom_boxplot() +
labs(title="Altura por Edad del Árbol", x="Edad", y="Altura (m)")
## Warning: Removed 2853 rows containing non-finite outside the scale range
## (`stat_boxplot()`).