base_datos <- read.csv(
"C:\\Users\\vlady\\Documents\\debers alexa no borrar\\Mining_model_input_data.csv",
stringsAsFactors = FALSE
)
col_sic <- base_datos$PRIMARY_SIC
valid_sic <- !is.na(col_sic) & as.character(col_sic) != ""
sic_vals <- as.character(col_sic[valid_sic])
# Total de registros válidos (307,008) y faltantes (23,458) según ficha de variables[cite: 1]
n_validos <- length(sic_vals)
n_faltantes <- sum(is.na(col_sic) | as.character(col_sic) == "")
data.frame(
Variable = "PRIMARY_SIC",
Tipo = "Cualitativo / Nominal",
Registros_Validos = n_validos,
Registros_Faltantes = n_faltantes
)
## Variable Tipo Registros_Validos Registros_Faltantes
## 1 PRIMARY_SIC Cualitativo / Nominal 307008 23458
ni)tabla_var10_fa <- aggregate(
list(ni = sic_vals),
by = list(Variable = sic_vals),
FUN = length
)
tabla_var10_fa <- tabla_var10_fa[order(-tabla_var10_fa$ni), ]
gt(tabla_var10_fa) |>
tab_header(
title = "Tabla N° 10",
subtitle = "Distribución de Frecuencia Absoluta (PRIMARY_SIC)"
) |>
cols_label(
Variable = "Sector Industrial (SIC)",
ni = "Frecuencia absoluta (ni)"
) |>
grand_summary_rows(
columns = ni,
fns = list(Total = ~sum(., na.rm = TRUE)),
fmt = ~fmt_number(., decimals = 0)
)
| Tabla N° 10 | ||
| Distribución de Frecuencia Absoluta (PRIMARY_SIC) | ||
| Sector Industrial (SIC) | Frecuencia absoluta (ni) | |
|---|---|---|
| Construction Sand and Gravel | 139287 | |
| Crushed, Broken Limestone NEC | 44841 | |
| Coal (Bituminous) | 22866 | |
| Crushed, Broken Stone NEC | 20292 | |
| Dimension Stone NEC | 10059 | |
| Sand, Common | 9021 | |
| Crushed, Broken Granite | 7296 | |
| Sand, Industrial NEC | 7158 | |
| Gold Ore | 3879 | |
| Dimension Sandstone | 3690 | |
| Crushed, Broken Sandstone | 3528 | |
| Dimension Limestone | 3369 | |
| Coal (Anthracite) | 3087 | |
| Crushed, Broken Traprock | 2529 | |
| Cement | 2412 | |
| Common Clays NEC | 2247 | |
| Lime | 1602 | |
| Gypsum | 1350 | |
| Clay, Ceramic, Refractory Mnls. | 1242 | |
| Dimension Granite | 1212 | |
| Dimension Slate | 1119 | |
| Common Shale | 1089 | |
| Kaolin and Ball Clay | 864 | |
| Copper Ore NEC | 744 | |
| Bentonite | 732 | |
| Fire Clay | 663 | |
| Iron Ore | 663 | |
| Coal (Lignite) | 621 | |
| Shell | 564 | |
| Lead-Zinc Ore | 528 | |
| Barite Barium Ore | 510 | |
| Crushed, Broken Slate | 480 | |
| Crushed, Broken Basalt | 450 | |
| Misc. Nonmetallic Mnls. NEC | 417 | |
| Salt | 396 | |
| Crushed, Broken Marble | 327 | |
| Gemstones | 321 | |
| Pumice | 318 | |
| Talc | 309 | |
| Dimension Marble | 294 | |
| Diatomaceous Earth (Diatomite) | 288 | |
| Phosphate Rock | 288 | |
| Perlite | 258 | |
| Dimension Traprock | 240 | |
| Silver Ore | 234 | |
| Ground Silica | 231 | |
| Crushed, Broken Quartzite | 192 | |
| Mica | 192 | |
| Zinc | 168 | |
| Feldspar | 150 | |
| Leonardite | 144 | |
| Quartz, Crystal | 123 | |
| Potash | 120 | |
| Gilsonite | 108 | |
| Wollastonite | 108 | |
| Dimension Basalt | 96 | |
| Quartz, Ground | 96 | |
| Uranium Ore | 96 | |
| Zeolites | 93 | |
| Fluorspar | 84 | |
| Misc. Metal Ore NEC | 72 | |
| Molybdenum Ore | 72 | |
| Rare Earths Ore | 66 | |
| Chem. and Fertil. Mnls. NEC | 48 | |
| Chromite Chromium Ore | 48 | |
| Kyanite | 48 | |
| Magnetite | 48 | |
| Nickel Ore | 48 | |
| Platinum Group Ore | 48 | |
| Potassium Compounds | 48 | |
| Titanium Ore | 48 | |
| Trona | 48 | |
| Vermiculite | 48 | |
| Aluminum Ore-Bauxite | 45 | |
| Dimension Quartzite | 45 | |
| Oil Shale | 36 | |
| Soapstone, Crushed Dimension | 36 | |
| Pigment Minerals | 30 | |
| Crushed, Broken Mica | 27 | |
| Aplite | 24 | |
| Beryl-Beryllium Ore | 24 | |
| Boron Minerals | 24 | |
| Cobalt Ore | 24 | |
| Fullers Earth | 24 | |
| Garnet | 24 | |
| Graphite | 24 | |
| Magnesite | 24 | |
| Manganese Ore | 24 | |
| Olivine | 24 | |
| Potash, Soda, Borate Mnls. NEC | 24 | |
| Pyrophyllite | 24 | |
| Sapphire | 24 | |
| Tungsten Ore | 24 | |
| Turquoise | 24 | |
| Vanadium Ore | 24 | |
| Agate | 12 | |
| Oil Sand | 12 | |
| Emerald | 6 | |
| Total | — | 307,008 |
hi %)tabla_sic_df <- tabla_var10_fa
tabla_sic_df$hi_pct <- round((tabla_sic_df$ni / sum(tabla_sic_df$ni)) * 100, 2)
gt(tabla_sic_df) |>
tab_header(
title = "Tabla N° 11",
subtitle = "Distribución de Clasificación Industrial (PRIMARY_SIC)"
) |>
cols_label(
Variable = "Sector Industrial (SIC)",
ni = "ni",
hi_pct = "hi (%)"
) |>
grand_summary_rows(
columns = c(ni, hi_pct),
fns = list(Total = ~sum(., na.rm = TRUE)),
fmt = ~fmt_number(., decimals = 2)
)
| Tabla N° 11 | |||
| Distribución de Clasificación Industrial (PRIMARY_SIC) | |||
| Sector Industrial (SIC) | ni | hi (%) | |
|---|---|---|---|
| Construction Sand and Gravel | 139287 | 45.37 | |
| Crushed, Broken Limestone NEC | 44841 | 14.61 | |
| Coal (Bituminous) | 22866 | 7.45 | |
| Crushed, Broken Stone NEC | 20292 | 6.61 | |
| Dimension Stone NEC | 10059 | 3.28 | |
| Sand, Common | 9021 | 2.94 | |
| Crushed, Broken Granite | 7296 | 2.38 | |
| Sand, Industrial NEC | 7158 | 2.33 | |
| Gold Ore | 3879 | 1.26 | |
| Dimension Sandstone | 3690 | 1.20 | |
| Crushed, Broken Sandstone | 3528 | 1.15 | |
| Dimension Limestone | 3369 | 1.10 | |
| Coal (Anthracite) | 3087 | 1.01 | |
| Crushed, Broken Traprock | 2529 | 0.82 | |
| Cement | 2412 | 0.79 | |
| Common Clays NEC | 2247 | 0.73 | |
| Lime | 1602 | 0.52 | |
| Gypsum | 1350 | 0.44 | |
| Clay, Ceramic, Refractory Mnls. | 1242 | 0.40 | |
| Dimension Granite | 1212 | 0.39 | |
| Dimension Slate | 1119 | 0.36 | |
| Common Shale | 1089 | 0.35 | |
| Kaolin and Ball Clay | 864 | 0.28 | |
| Copper Ore NEC | 744 | 0.24 | |
| Bentonite | 732 | 0.24 | |
| Fire Clay | 663 | 0.22 | |
| Iron Ore | 663 | 0.22 | |
| Coal (Lignite) | 621 | 0.20 | |
| Shell | 564 | 0.18 | |
| Lead-Zinc Ore | 528 | 0.17 | |
| Barite Barium Ore | 510 | 0.17 | |
| Crushed, Broken Slate | 480 | 0.16 | |
| Crushed, Broken Basalt | 450 | 0.15 | |
| Misc. Nonmetallic Mnls. NEC | 417 | 0.14 | |
| Salt | 396 | 0.13 | |
| Crushed, Broken Marble | 327 | 0.11 | |
| Gemstones | 321 | 0.10 | |
| Pumice | 318 | 0.10 | |
| Talc | 309 | 0.10 | |
| Dimension Marble | 294 | 0.10 | |
| Diatomaceous Earth (Diatomite) | 288 | 0.09 | |
| Phosphate Rock | 288 | 0.09 | |
| Perlite | 258 | 0.08 | |
| Dimension Traprock | 240 | 0.08 | |
| Silver Ore | 234 | 0.08 | |
| Ground Silica | 231 | 0.08 | |
| Crushed, Broken Quartzite | 192 | 0.06 | |
| Mica | 192 | 0.06 | |
| Zinc | 168 | 0.05 | |
| Feldspar | 150 | 0.05 | |
| Leonardite | 144 | 0.05 | |
| Quartz, Crystal | 123 | 0.04 | |
| Potash | 120 | 0.04 | |
| Gilsonite | 108 | 0.04 | |
| Wollastonite | 108 | 0.04 | |
| Dimension Basalt | 96 | 0.03 | |
| Quartz, Ground | 96 | 0.03 | |
| Uranium Ore | 96 | 0.03 | |
| Zeolites | 93 | 0.03 | |
| Fluorspar | 84 | 0.03 | |
| Misc. Metal Ore NEC | 72 | 0.02 | |
| Molybdenum Ore | 72 | 0.02 | |
| Rare Earths Ore | 66 | 0.02 | |
| Chem. and Fertil. Mnls. NEC | 48 | 0.02 | |
| Chromite Chromium Ore | 48 | 0.02 | |
| Kyanite | 48 | 0.02 | |
| Magnetite | 48 | 0.02 | |
| Nickel Ore | 48 | 0.02 | |
| Platinum Group Ore | 48 | 0.02 | |
| Potassium Compounds | 48 | 0.02 | |
| Titanium Ore | 48 | 0.02 | |
| Trona | 48 | 0.02 | |
| Vermiculite | 48 | 0.02 | |
| Aluminum Ore-Bauxite | 45 | 0.01 | |
| Dimension Quartzite | 45 | 0.01 | |
| Oil Shale | 36 | 0.01 | |
| Soapstone, Crushed Dimension | 36 | 0.01 | |
| Pigment Minerals | 30 | 0.01 | |
| Crushed, Broken Mica | 27 | 0.01 | |
| Aplite | 24 | 0.01 | |
| Beryl-Beryllium Ore | 24 | 0.01 | |
| Boron Minerals | 24 | 0.01 | |
| Cobalt Ore | 24 | 0.01 | |
| Fullers Earth | 24 | 0.01 | |
| Garnet | 24 | 0.01 | |
| Graphite | 24 | 0.01 | |
| Magnesite | 24 | 0.01 | |
| Manganese Ore | 24 | 0.01 | |
| Olivine | 24 | 0.01 | |
| Potash, Soda, Borate Mnls. NEC | 24 | 0.01 | |
| Pyrophyllite | 24 | 0.01 | |
| Sapphire | 24 | 0.01 | |
| Tungsten Ore | 24 | 0.01 | |
| Turquoise | 24 | 0.01 | |
| Vanadium Ore | 24 | 0.01 | |
| Agate | 12 | 0.00 | |
| Oil Sand | 12 | 0.00 | |
| Emerald | 6 | 0.00 | |
| Total | — | 307,008.00 | 100.06 |
tabla_sic_aj <- tabla_var10_fa
tabla_sic_aj$ni_ajustada <- round((tabla_sic_aj$ni / sum(tabla_sic_aj$ni)) * 1000, 2)
gt(tabla_sic_aj) |>
tab_header(
title = "Frecuencia Absoluta Ajustada",
subtitle = "Distribución Ajustada por cada 1,000 registros (PRIMARY_SIC)"
) |>
cols_label(
Variable = "Sector Industrial (SIC)",
ni = "Frecuencia absoluta (ni)",
ni_ajustada = "Frecuencia ajustada (por 1,000)"
) |>
grand_summary_rows(
columns = c(ni, ni_ajustada),
fns = list(Total = ~sum(., na.rm = TRUE)),
fmt = ~fmt_number(., decimals = 2)
)
| Frecuencia Absoluta Ajustada | |||
| Distribución Ajustada por cada 1,000 registros (PRIMARY_SIC) | |||
| Sector Industrial (SIC) | Frecuencia absoluta (ni) | Frecuencia ajustada (por 1,000) | |
|---|---|---|---|
| Construction Sand and Gravel | 139287 | 453.69 | |
| Crushed, Broken Limestone NEC | 44841 | 146.06 | |
| Coal (Bituminous) | 22866 | 74.48 | |
| Crushed, Broken Stone NEC | 20292 | 66.10 | |
| Dimension Stone NEC | 10059 | 32.76 | |
| Sand, Common | 9021 | 29.38 | |
| Crushed, Broken Granite | 7296 | 23.76 | |
| Sand, Industrial NEC | 7158 | 23.32 | |
| Gold Ore | 3879 | 12.63 | |
| Dimension Sandstone | 3690 | 12.02 | |
| Crushed, Broken Sandstone | 3528 | 11.49 | |
| Dimension Limestone | 3369 | 10.97 | |
| Coal (Anthracite) | 3087 | 10.06 | |
| Crushed, Broken Traprock | 2529 | 8.24 | |
| Cement | 2412 | 7.86 | |
| Common Clays NEC | 2247 | 7.32 | |
| Lime | 1602 | 5.22 | |
| Gypsum | 1350 | 4.40 | |
| Clay, Ceramic, Refractory Mnls. | 1242 | 4.05 | |
| Dimension Granite | 1212 | 3.95 | |
| Dimension Slate | 1119 | 3.64 | |
| Common Shale | 1089 | 3.55 | |
| Kaolin and Ball Clay | 864 | 2.81 | |
| Copper Ore NEC | 744 | 2.42 | |
| Bentonite | 732 | 2.38 | |
| Fire Clay | 663 | 2.16 | |
| Iron Ore | 663 | 2.16 | |
| Coal (Lignite) | 621 | 2.02 | |
| Shell | 564 | 1.84 | |
| Lead-Zinc Ore | 528 | 1.72 | |
| Barite Barium Ore | 510 | 1.66 | |
| Crushed, Broken Slate | 480 | 1.56 | |
| Crushed, Broken Basalt | 450 | 1.47 | |
| Misc. Nonmetallic Mnls. NEC | 417 | 1.36 | |
| Salt | 396 | 1.29 | |
| Crushed, Broken Marble | 327 | 1.07 | |
| Gemstones | 321 | 1.05 | |
| Pumice | 318 | 1.04 | |
| Talc | 309 | 1.01 | |
| Dimension Marble | 294 | 0.96 | |
| Diatomaceous Earth (Diatomite) | 288 | 0.94 | |
| Phosphate Rock | 288 | 0.94 | |
| Perlite | 258 | 0.84 | |
| Dimension Traprock | 240 | 0.78 | |
| Silver Ore | 234 | 0.76 | |
| Ground Silica | 231 | 0.75 | |
| Crushed, Broken Quartzite | 192 | 0.63 | |
| Mica | 192 | 0.63 | |
| Zinc | 168 | 0.55 | |
| Feldspar | 150 | 0.49 | |
| Leonardite | 144 | 0.47 | |
| Quartz, Crystal | 123 | 0.40 | |
| Potash | 120 | 0.39 | |
| Gilsonite | 108 | 0.35 | |
| Wollastonite | 108 | 0.35 | |
| Dimension Basalt | 96 | 0.31 | |
| Quartz, Ground | 96 | 0.31 | |
| Uranium Ore | 96 | 0.31 | |
| Zeolites | 93 | 0.30 | |
| Fluorspar | 84 | 0.27 | |
| Misc. Metal Ore NEC | 72 | 0.23 | |
| Molybdenum Ore | 72 | 0.23 | |
| Rare Earths Ore | 66 | 0.21 | |
| Chem. and Fertil. Mnls. NEC | 48 | 0.16 | |
| Chromite Chromium Ore | 48 | 0.16 | |
| Kyanite | 48 | 0.16 | |
| Magnetite | 48 | 0.16 | |
| Nickel Ore | 48 | 0.16 | |
| Platinum Group Ore | 48 | 0.16 | |
| Potassium Compounds | 48 | 0.16 | |
| Titanium Ore | 48 | 0.16 | |
| Trona | 48 | 0.16 | |
| Vermiculite | 48 | 0.16 | |
| Aluminum Ore-Bauxite | 45 | 0.15 | |
| Dimension Quartzite | 45 | 0.15 | |
| Oil Shale | 36 | 0.12 | |
| Soapstone, Crushed Dimension | 36 | 0.12 | |
| Pigment Minerals | 30 | 0.10 | |
| Crushed, Broken Mica | 27 | 0.09 | |
| Aplite | 24 | 0.08 | |
| Beryl-Beryllium Ore | 24 | 0.08 | |
| Boron Minerals | 24 | 0.08 | |
| Cobalt Ore | 24 | 0.08 | |
| Fullers Earth | 24 | 0.08 | |
| Garnet | 24 | 0.08 | |
| Graphite | 24 | 0.08 | |
| Magnesite | 24 | 0.08 | |
| Manganese Ore | 24 | 0.08 | |
| Olivine | 24 | 0.08 | |
| Potash, Soda, Borate Mnls. NEC | 24 | 0.08 | |
| Pyrophyllite | 24 | 0.08 | |
| Sapphire | 24 | 0.08 | |
| Tungsten Ore | 24 | 0.08 | |
| Turquoise | 24 | 0.08 | |
| Vanadium Ore | 24 | 0.08 | |
| Agate | 12 | 0.04 | |
| Oil Sand | 12 | 0.04 | |
| Emerald | 6 | 0.02 | |
| Total | — | 307,008.00 | 1,000.08 |
ni, Top 10 + Otros)top_n <- 10
graf10 <- head(tabla_sic_df[, c("Variable", "ni")], top_n)
if (nrow(tabla_sic_df) > top_n) {
otros <- data.frame(
Variable = "Otros",
ni = sum(tabla_sic_df$ni[-(1:top_n)])
)
graf10 <- rbind(graf10, otros)
}
graf10$hi_pct <- round(graf10$ni / sum(graf10$ni) * 100, 2)
ggplot(graf10, aes(x = reorder(Variable, ni), y = ni)) +
geom_col(fill = "darkorange") +
geom_text(aes(label = paste0(hi_pct, "%")), hjust = -0.1, size = 3.5) +
coord_flip() +
expand_limits(y = max(graf10$ni) * 1.12) +
labs(
title = "Distribución de Clasificación Industrial (PRIMARY_SIC)",
x = "Sector Industrial (SIC)",
y = "Frecuencia absoluta (ni)"
) +
theme_minimal(base_size = 12)
hi %, Top 10 + Otros)grafica10_fr <- graf10[, c("Variable", "hi_pct")]
ggplot(grafica10_fr, aes(x = reorder(Variable, hi_pct), y = hi_pct)) +
geom_col(fill = "mediumpurple") +
geom_text(
aes(label = paste0(hi_pct, "%")),
hjust = -0.1,
size = 3.5
) +
coord_flip() +
expand_limits(y = max(grafica10_fr$hi_pct) * 1.15) +
labs(
title = "Distribución de Frecuencia Relativa (PRIMARY_SIC)",
subtitle = "Principales 10 sectores industriales y otros",
x = "Sector Industrial (SIC)",
y = "Frecuencia relativa (hi %)"
) +
theme_minimal(base_size = 12)
ggplot(graf10, aes(x = "", y = hi_pct, fill = Variable)) +
geom_col(width = 1, color = "white") +
coord_polar(theta = "y") +
geom_text(
aes(label = ifelse(hi_pct >= 3, paste0(hi_pct, "%"), "")),
position = position_stack(vjust = 0.5),
size = 3.5
) +
labs(
title = "Distribución Porcentual de Clasificación Industrial (PRIMARY_SIC)",
fill = "SIC"
) +
theme_void(base_size = 12)
indicadores_sic <- tabla_sic_df |>
mutate(
hi = round(ni / sum(ni), 4),
ni_ajustada_1000 = round((ni / sum(ni)) * 1000, 2)
)
head(indicadores_sic, 10)
## Variable ni hi_pct hi ni_ajustada_1000
## 18 Construction Sand and Gravel 139287 45.37 0.4537 453.69
## 22 Crushed, Broken Limestone NEC 44841 14.61 0.1461 146.06
## 13 Coal (Bituminous) 22866 7.45 0.0745 74.48
## 28 Crushed, Broken Stone NEC 20292 6.61 0.0661 66.10
## 38 Dimension Stone NEC 10059 3.28 0.0328 32.76
## 82 Sand, Common 9021 2.94 0.0294 29.38
## 21 Crushed, Broken Granite 7296 2.38 0.0238 23.76
## 83 Sand, Industrial NEC 7158 2.33 0.0233 23.32
## 48 Gold Ore 3879 1.26 0.0126 12.63
## 36 Dimension Sandstone 3690 1.20 0.0120 12.02
Los resultados muestran que la distribución de los códigos presenta una mayor frecuencia en el código 08123, con 2.679 registros, seguido del 42115 con 2.155 y el 42107 con 1.968. Esto evidencia que los registros del modelo de uso de agua en la minería de Estados Unidos se encuentran distribuidos en numerosas ubicaciones, aunque algunas concentran una mayor cantidad de observaciones.