Escritura

setwd("/cloud/project")

Datos <- read.csv("DataSet_.csv", sep = ";", fileEncoding = "latin1")

install.packages("dplyr")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
install.packages("ggplot2")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library(ggplot2)

Tabla Base

Curvature <- Datos$curvature_type
TDF_curvature <- table(Curvature)

tabla_curvature <- as.data.frame(TDF_curvature)
hi <- tabla_curvature$Freq/sum(tabla_curvature$Freq)
hi_porc <- hi*100

tabla_CURVATURE <- data.frame(tabla_curvature, hi_porc)

colnames(tabla_CURVATURE)[1] <- "TipoCurvatura"

Agrupación

tabla_resumen <- tabla_CURVATURE %>%
  mutate(grupo = case_when(
    grepl("Valles", TipoCurvatura, ignore.case = TRUE) ~ "Superficies cóncavas / Valles",
    grepl("convexas", TipoCurvatura, ignore.case = TRUE) ~ "Superficies convexas / Crestas",
    grepl("planas", TipoCurvatura, ignore.case = TRUE) ~ "Superficies planas o intermedias",
    TRUE ~ "Otros" 
  )) %>%
  group_by(grupo) %>%
  summarise(
    Frecuencia = sum(Freq),
    Porcentaje = sum(hi_porc)
  ) %>%
  arrange(desc(Frecuencia))

colnames(tabla_resumen) <- c("Curvatura","ni","hi (%)")
tabla_resumen
## # A tibble: 4 × 3
##   Curvatura                           ni `hi (%)`
##   <chr>                            <int>    <dbl>
## 1 Superficies planas o intermedias  5846  81.9   
## 2 Superficies convexas / Crestas     675   9.45  
## 3 Superficies cóncavas / Valles      620   8.68  
## 4 Otros                                1   0.0140

Totales

totales <- c(
  Curvatura = "TOTAL",
  ni = sum(tabla_resumen$ni),
  hi = sum(tabla_resumen$`hi (%)`)
)

tabla_Curvature_Final <- rbind(tabla_resumen, totales)
tabla_Curvature_Final
## # A tibble: 5 × 3
##   Curvatura                        ni    `hi (%)`          
##   <chr>                            <chr> <chr>             
## 1 Superficies planas o intermedias 5846  81.853822458695   
## 2 Superficies convexas / Crestas   675   9.45113413609633  
## 3 Superficies cóncavas / Valles    620   8.681041725007    
## 4 Otros                            1     0.0140016802016242
## 5 TOTAL                            7142  100

GRÁFICOS

Gráfico 1 – Frecuencia local

par(mar = c(12, 4, 4, 2))
barplot(tabla_resumen$ni,main="Gráfica N°1: Distribución del tipo de curvatura",
        ylab = "Cantidad",
        col = "skyblue",
        names.arg=tabla_resumen$Curvatura,
        cex.names = 0.7, las = 2)
mtext("Tipo de Curvatura", side = 1, line = 11)

Gráfico 2 – Frecuencia global

barplot(tabla_resumen$ni,main="Gráfica N°2: Distribución del tipo de curvatura (Global)",
        ylab = "Cantidad",
        col = "skyblue",
        ylim = c(0,8000), 
        names.arg=tabla_resumen$Curvatura,
        cex.names = 0.7, las = 2)
mtext("Tipo de Curvatura", side = 1, line = 11)

Gráfico 3 – Porcentaje local

barplot(tabla_resumen$`hi (%)`,main="Gráfica N°3: Distribución porcentual del tipo de curvatura",
        ylab = "Porcentaje %",
        col = "skyblue",
        names.arg=tabla_resumen$Curvatura,
        cex.names = 0.7, las = 2)
mtext("Tipo de Curvatura", side = 1, line = 11)

Gráfico 4 – Porcentaje global

barplot(tabla_resumen$`hi (%)`,main="Gráfica N°4: Distribución porcentual global",
        ylab = "Porcentaje %",
        col = "skyblue",
        ylim = c(0,100),
        names.arg=tabla_resumen$Curvatura,
        cex.names = 0.7, las = 2)
mtext("Tipo de Curvatura", side = 1, line = 11)

Gráfico 5 – Diagrama Circular

pie(tabla_resumen$`hi (%)`,
    main = "Gráfica N°5: Distribución porcentual del tipo de curvatura",
    radius = 0.9,
    labels = paste0(round(tabla_resumen$`hi (%)`,2),"%"),
    col = colores <- c(rev(heat.colors(length(tabla_resumen$Curvatura)))),
    cex = 0.6)

legend(x = 0.75, y = 1,
       legend = tabla_resumen$Curvatura,
       fill = colores,
       cex = 0.6,
       title = "Tipo de Curvatura")

par(xpd = TRUE)

Tabla de Conlusiones

install.packages("knitr")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.5'
## (as 'lib' is unspecified)
library(knitr)

tabla_indicadores <- data.frame(
  "Variable" = "Tipo de Curvatura",
  "Rango" = "Formas del terreno",
  "X" = "-",
  "Me" = "-",
  "Mo" = "Planas o intermedias",
  "V" = "-",
  "Sd" = "-",
  "Cv" = "-",
  "As" = "-",
  "K" = "-",
  "Valores Atipicos" = "-"
)

kable(tabla_indicadores, align = 'c', caption = "Conclusiones de la variable Tipo de Curvatura")
Conclusiones de la variable Tipo de Curvatura
Variable Rango X Me Mo V Sd Cv As K Valores.Atipicos
Tipo de Curvatura Formas del terreno - - Planas o intermedias - - - - - -